Skip to content

Commit

Permalink
Merge branch 'develop' into turnoff-cc-verioning
Browse files Browse the repository at this point in the history
  • Loading branch information
cannarocks authored Aug 9, 2024
2 parents 96eef67 + ed9fb3c commit 02ec944
Show file tree
Hide file tree
Showing 30 changed files with 1,777 additions and 138 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ coverage/
keys/*
!/**/.gitkeep.idea
.idea
.vscode/*.log
.vscode/*.log
.aider*
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"@appquality/tryber-database": "^0.41.1",
"@appquality/tryber-database": "^0.41.9",
"@appquality/wp-auth": "^1.0.7",
"@googlemaps/google-maps-services-js": "^3.3.7",
"@sendgrid/mail": "^7.6.0",
Expand Down
4 changes: 4 additions & 0 deletions src/features/db/class/PreselectionFormFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type PreselectionFormFieldsType = {
| "address"
| `cuf_${number}`;
options: string;
invalid_options: string;
question: string;
priority: number;
};
Expand All @@ -26,6 +27,7 @@ class PreselectionFormFieldsObject {
options: PreselectionFormFieldsType["options"];
question: PreselectionFormFieldsType["question"];
priority: PreselectionFormFieldsType["priority"];
invalid_options: PreselectionFormFieldsType["invalid_options"];

constructor(item: PreselectionFormFieldsType) {
this.id = item.id;
Expand All @@ -35,6 +37,7 @@ class PreselectionFormFieldsObject {
this.options = item.options;
this.question = item.question;
this.priority = item.priority;
this.invalid_options = item.invalid_options;
}

public getOptions(): string[] | number[] {
Expand Down Expand Up @@ -63,6 +66,7 @@ class Table extends Database<{
"options",
"question",
"priority",
"invalid_options",
],
});
}
Expand Down
165 changes: 131 additions & 34 deletions src/reference/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1248,6 +1248,14 @@ paths:
type: string
value:
type: string
status:
type: string
x-stoplight:
id: 3f1wy22lgngzn
enum:
- candidate
- excluded
- selected
required:
- id
- name
Expand Down Expand Up @@ -1702,6 +1710,7 @@ paths:
- onlyAccepted
- onlyCandidates
- all
- candidatesAndExcluded
in: query
name: show
description: Show accepted/candidates or both
Expand Down Expand Up @@ -6241,6 +6250,7 @@ paths:
- start_date
- end_date
- close_date
- visibility
in: query
name: orderBy
description: The field for item order
Expand Down Expand Up @@ -6925,9 +6935,15 @@ paths:
type: array
items:
allOf:
- $ref: '#/components/schemas/PreselectionFormQuestion'
- type: object
properties:
- properties:
question:
type: string
x-stoplight:
id: ir6xgrpexauf5
short_name:
type: string
x-stoplight:
id: bl9s0k131fjp4
value:
oneOf:
- type: integer
Expand All @@ -6953,7 +6969,48 @@ paths:
id:
type: number
required:
- question
- id
- x-stoplight:
id: 76ya1n62vrxoj
oneOf:
- properties:
type:
$ref: '#/components/schemas/PreselectionQuestionSimple'
required:
- type
- x-stoplight:
id: age6qie67x6dt
properties:
type:
$ref: '#/components/schemas/PreselectionQuestionMultiple'
options:
type: array
x-stoplight:
id: 3eqfw8hp0j217
items:
x-stoplight:
id: u67gsrnn8bhvb
type: string
required:
- type
- options
- x-stoplight:
id: v6nzvavd1bbnh
properties:
type:
$ref: '#/components/schemas/PreselectionQuestionCuf'
options:
type: array
x-stoplight:
id: ilyb6ci3tao5c
items:
x-stoplight:
id: 511phg4idvt3g
type: number
required:
- type
type: object
examples:
example-1:
value:
Expand Down Expand Up @@ -10287,6 +10344,12 @@ components:
type: integer
totalSpots:
type: integer
type:
type: string
enum:
- available
- unavailable
- candidate
CampaignRequired:
description: ''
type: object
Expand Down Expand Up @@ -10493,59 +10556,68 @@ components:
PreselectionFormQuestion:
title: PreselectionFormQuestion
allOf:
- type: object
properties:
- properties:
question:
type: string
short_name:
type: string
required:
- question
- oneOf:
- type: object
properties:
- properties:
type:
type: string
enum:
- text
$ref: '#/components/schemas/PreselectionQuestionSimple'
required:
- type
- type: object
properties:
- properties:
type:
type: string
enum:
- multiselect
- select
- radio
$ref: '#/components/schemas/PreselectionQuestionMultiple'
options:
type: array
x-stoplight:
id: xdbut0hjezieh
items:
type: string
x-stoplight:
id: cln0chyj7s107
type: object
properties:
value:
type: string
x-stoplight:
id: ifhnncm4ap0l8
isInvalid:
type: boolean
x-stoplight:
id: 6imsh5mbep30d
required:
- value
required:
- type
- options
- type: object
properties:
- properties:
type:
type: string
pattern: '^cuf_[0-9]*$'
$ref: '#/components/schemas/PreselectionQuestionCuf'
options:
type: array
x-stoplight:
id: 98p0edyoy9t49
items:
type: integer
required:
- type
- type: object
properties:
type:
type: string
enum:
- gender
- phone_number
- address
x-stoplight:
id: lri0oems0d8by
type: object
properties:
value:
type: number
x-stoplight:
id: hrwvvg2r2jm4v
isInvalid:
type: boolean
x-stoplight:
id: wiocd6n2pq0z5
required:
- value
required:
- type
type: object
Project:
title: Project
type: object
Expand Down Expand Up @@ -10898,6 +10970,31 @@ components:
- title
- startDate
- deviceList
PreselectionQuestionSimple:
title: PreselectionQuestionSimple
x-stoplight:
id: huxuwdbvi0pep
type: string
enum:
- gender
- text
- phone_number
- address
PreselectionQuestionMultiple:
title: PreselectionQuestionMultiple
x-stoplight:
id: op7khbr8grgql
type: string
enum:
- multiselect
- select
- radio
PreselectionQuestionCuf:
title: PreselectionQuestionCuf
x-stoplight:
id: 5diemuprwjolx
type: string
pattern: '^cuf_[0-9]*$'
securitySchemes:
JWT:
type: http
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ class CandidateDevices implements CandidateData {
private campaignId: number;
private candidateIds: number[];
private filters?: { os?: string[] };
private show: "onlyAccepted" | "onlyCandidates" | "all" = "all";
private show:
| "onlyAccepted"
| "onlyCandidates"
| "all"
| "candidatesAndExcluded" = "all";

private _devices:
| {
Expand Down Expand Up @@ -36,7 +40,7 @@ class CandidateDevices implements CandidateData {
campaignId: number;
candidateIds: number[];
filters?: { os?: string[] };
show: "onlyAccepted" | "onlyCandidates" | "all";
show: "onlyAccepted" | "onlyCandidates" | "all" | "candidatesAndExcluded";
}) {
this.candidateIds = candidateIds;
this.filters = filters;
Expand Down
23 changes: 19 additions & 4 deletions src/routes/campaigns/campaignId/candidates/_get/Candidates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ import { tryber } from "@src/features/database";

class Candidates {
private campaign_id: number;
private show: "onlyAccepted" | "onlyCandidates" | "all" = "all";
private show:
| "onlyAccepted"
| "onlyCandidates"
| "all"
| "candidatesAndExcluded" = "all";
constructor({
campaign_id,
show,
}: {
campaign_id: number;
show: "onlyAccepted" | "onlyCandidates" | "all";
show: "onlyAccepted" | "onlyCandidates" | "all" | "candidatesAndExcluded";
}) {
this.campaign_id = campaign_id;
this.show = show;
Expand All @@ -29,7 +33,8 @@ class Candidates {
.select(
tryber.ref("id").withSchema("wp_appq_evd_profile"),
"name",
"surname"
"surname",
"accepted"
)
.where("campaign_id", this.campaign_id)
.where("name", "<>", "Deleted User")
Expand All @@ -40,9 +45,19 @@ class Candidates {
query.where("accepted", 1);
} else if (this.show === "onlyCandidates") {
query.where("accepted", 0);
} else if (this.show === "candidatesAndExcluded") {
query.whereIn("accepted", [0, -1]);
}

return await query;
return (await query).map((candidate) => ({
...candidate,
status:
candidate.accepted === 1
? ("selected" as const)
: candidate.accepted === 0
? ("candidate" as const)
: ("excluded" as const),
}));
}
}

Expand Down
1 change: 1 addition & 0 deletions src/routes/campaigns/campaignId/candidates/_get/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ export default class RouteItem extends UserRoute<{
age: candidate.age,
questions: candidate.questions,
levels: candidate.levels,
status: candidate.status,
};
}),
size: candidates.length,
Expand Down
Loading

0 comments on commit 02ec944

Please sign in to comment.