From b2b3a7b46201feb795fb8a39efc31e9f2af2b167 Mon Sep 17 00:00:00 2001
From: Korzinkayablok
Date: Tue, 14 Sep 2021 14:43:09 +0300
Subject: [PATCH 1/3] - ProfileSearchForm now contains achievements array.
Profile index action by id, by params response now contains achievements
array
---
frontend/modules/api/models/ProfileSearchForm.php | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/frontend/modules/api/models/ProfileSearchForm.php b/frontend/modules/api/models/ProfileSearchForm.php
index c6a5075..23f67f0 100644
--- a/frontend/modules/api/models/ProfileSearchForm.php
+++ b/frontend/modules/api/models/ProfileSearchForm.php
@@ -20,6 +20,8 @@ class ProfileSearchForm extends Model
public $limit = 10;
public $offset = 0;
public $skills;
+ public $achievements;
+
public $position_id;
public $id;
@@ -28,6 +30,7 @@ class ProfileSearchForm extends Model
return [
[['id', 'limit', 'offset', 'position_id'], 'safe'],
[['skills'], 'checkIsArray'],
+ [['achievements'], 'checkIsArray'],
];
}
@@ -45,6 +48,7 @@ class ProfileSearchForm extends Model
return UserCard::find()
->where(['id' => $this->id])
->with(['skillValues'])
+ ->with(['achievements'])
->asArray()
->one();
}
@@ -67,6 +71,16 @@ class ProfileSearchForm extends Model
$model->joinWith('skillValues');
}
+ if($this->achievements){
+ $model->joinWith(['achievements']);
+ $this->achievements = explode(',', $this->achievements);
+ $model->where(['achievement_user_card.achievement_id' => $this->achievements]);
+ $model->having('COUNT(DISTINCT achievement_id) = ' . count($this->achievements));
+ }
+ else{
+ $model->joinWith('achievements');
+ }
+
$model->andFilterWhere(['position_id' => $this->position_id]);
$model->andWhere(['status' => [4, 12]]);
From 8182a9236a620a0e25dfe8096088504f55ad179b Mon Sep 17 00:00:00 2001
From: Korzinkayablok
Date: Tue, 14 Sep 2021 17:23:28 +0300
Subject: [PATCH 2/3] Remove short open tag
---
backend/modules/card/views/user-card/view.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/backend/modules/card/views/user-card/view.php b/backend/modules/card/views/user-card/view.php
index 90eb548..ee87e0b 100755
--- a/backend/modules/card/views/user-card/view.php
+++ b/backend/modules/card/views/user-card/view.php
@@ -100,7 +100,7 @@ $this->params['breadcrumbs'][] = $this->title;
Достижения
= Html::tag('img', null,
['src' => $achievement['achievement']->img, 'height' => '50px', 'width' => '50px']
From 6c14d4c7e1d223cfc30af3546cf2017cb251e7bb Mon Sep 17 00:00:00 2001
From: Korzinkayablok
Date: Wed, 15 Sep 2021 16:14:08 +0300
Subject: [PATCH 3/3] Removed achievements from profile search form filters.
Added doc for api/profile
---
docs/api/main.md | 77 ++++++++++++++++++-
.../modules/api/models/ProfileSearchForm.php | 20 ++---
2 files changed, 78 insertions(+), 19 deletions(-)
diff --git a/docs/api/main.md b/docs/api/main.md
index 4706b6e..0176be5 100644
--- a/docs/api/main.md
+++ b/docs/api/main.md
@@ -1,4 +1,4 @@
-# Документация API
+# Документация API
## Навыки
### Популярные навыки
@@ -54,22 +54,91 @@
Пример запроса:
-`https://guild.craft-group.xyz/api/profile?limit=5&offset=5&skills=1`
+`https://guild.craft-group.xyz/api/profile?limit=5&offset=5&skills=1,2`
+
+
+ Возвращает массив объектов Профилей.
+ Каждый объект Профиля имеет такой вид:
+
+
+```json5
+{
+ "id": "1",
+ "fio": "f23f",
+ "passport": "f23",
+ "photo": "''",
+ "email": "f",
+ "gender": "1",
+ "dob": "2021-09-17",
+ "status": "2",
+ "created_at": "2021-09-08 16:30:34",
+ "updated_at": "2021-09-09 08:41:02",
+ "resume": "",
+ "salary": "",
+ "position_id": "1",
+ "deleted_at": null,
+ "id_user": "1",
+ "city": "",
+ "link_vk": "",
+ "link_telegram": "",
+ "vc_text": "",
+ "level": "2", //
+ "vc_text_short": "",
+ "years_of_exp": "0",
+ "specification": "",
+ "skillValues": [ //Массив навыков привязанных к этому профилю
+ {
+ "id": "1",
+ "card_id": "1", //card_id из таблицы card_skill
+ "skill_id": "1",//skill_id из таблицы card_skill
+ "skill": {
+ "id": "1", //id из таблицы skill
+ "name": "SQL",
+ "category_id": "1"
+ }
+ },
+ //...
+ ],
+ "achievements": [ //Массив достижений привязанных к этому профилю
+ {
+ "id": "7",
+ "user_card_id": "1",//user_card_id из таблицы achievement_user_card
+ "achievement_id": "1",//achievement_id из таблицы achievement_user_card
+ "achievement": {
+ "id": "1", //id из таблицы achievement
+ "slug": "newguy",
+ "title": "Новичок",
+ "img": "",
+ "description": "Ты начал у нас работу",
+ "status": "1" // 1 - Активно, 2 - Неактивно
+ }
+ },
+ //...
+ ]
+}
+```
+
### Одна запись
`https://guild.craft-group.xyz/api/profile/{id}`
Для того, чтобы получить данные одной записи необходимо отправить GET запрос
- на URL https://guild.craft-group.xyz/api/profile/{id} , где id это идинтификатор
+ на URL https://guild.craft-group.xyz/api/profile/{id} , где id это идентификатор
профиля.
-
+
Пример запроса:
`https://guild.craft-group.xyz/api/profile/6`
+
+ Возвращает объект Профиля.
+ Как выглядит можно посмотреть выше.
+
+
+
### Пригласить на собеседование
`https://guild.craft-group.xyz/api/profile/add-to-interview`
diff --git a/frontend/modules/api/models/ProfileSearchForm.php b/frontend/modules/api/models/ProfileSearchForm.php
index 23f67f0..b3033d4 100644
--- a/frontend/modules/api/models/ProfileSearchForm.php
+++ b/frontend/modules/api/models/ProfileSearchForm.php
@@ -20,7 +20,6 @@ class ProfileSearchForm extends Model
public $limit = 10;
public $offset = 0;
public $skills;
- public $achievements;
public $position_id;
public $id;
@@ -30,7 +29,6 @@ class ProfileSearchForm extends Model
return [
[['id', 'limit', 'offset', 'position_id'], 'safe'],
[['skills'], 'checkIsArray'],
- [['achievements'], 'checkIsArray'],
];
}
@@ -71,20 +69,12 @@ class ProfileSearchForm extends Model
$model->joinWith('skillValues');
}
- if($this->achievements){
- $model->joinWith(['achievements']);
- $this->achievements = explode(',', $this->achievements);
- $model->where(['achievement_user_card.achievement_id' => $this->achievements]);
- $model->having('COUNT(DISTINCT achievement_id) = ' . count($this->achievements));
- }
- else{
- $model->joinWith('achievements');
- }
+ $model->joinWith('achievements');
- $model->andFilterWhere(['position_id' => $this->position_id]);
-
- $model->andWhere(['status' => [4, 12]]);
- $model->andWhere(['deleted_at' => null]);
+// $model->andFilterWhere(['position_id' => $this->position_id]);
+//
+// $model->andWhere(['status' => [4, 12]]);
+// $model->andWhere(['deleted_at' => null]);
$model->groupBy('card_skill.card_id');