Skip to content

Commit 153b285

Browse files
committed
final fixes for challenge #30056080 PREFLIGHT CHECKLIST
1 parent 9c63cf9 commit 153b285

File tree

3 files changed

+324
-1
lines changed

3 files changed

+324
-1
lines changed

services/MissionService.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ getPilotChecklist.schema = {
305305
*
306306
* @param {String} id mission id
307307
* @param {String} pilotId pilot id
308-
* @return {Object} mission status, question list and a pilot checklist if available
308+
* @return {Object} mission name, mission status, question list and a pilot checklist if available
309309
*/
310310
function* getPilotChecklist(id, pilotId) {
311311
const mission = yield Mission.findOne({_id: id});
@@ -319,6 +319,7 @@ function* getPilotChecklist(id, pilotId) {
319319
}
320320

321321
const response = {
322+
missionName: mission.missionName,
322323
missionStatus: mission.status,
323324
};
324325
// get questions texts to send them in response

swagger.json

+319
Original file line numberDiff line numberDiff line change
@@ -3840,6 +3840,281 @@
38403840
}
38413841
}
38423842
}
3843+
},
3844+
"/pilot/missions": {
3845+
"get": {
3846+
"description": "Get list of missions for the current logged in pilot. Pilot role only.",
3847+
"tags": [
3848+
"pilot",
3849+
"mission"
3850+
],
3851+
"security": [
3852+
{
3853+
"Bearer": []
3854+
}
3855+
],
3856+
"parameters": [
3857+
{
3858+
"name": "offset",
3859+
"in": "query",
3860+
"description": "the search offset",
3861+
"required": false,
3862+
"type": "integer"
3863+
},
3864+
{
3865+
"name": "limit",
3866+
"in": "query",
3867+
"description": "the search limit",
3868+
"required": false,
3869+
"type": "integer"
3870+
},
3871+
{
3872+
"name": "sortBy",
3873+
"in": "query",
3874+
"description": "the sort field. Allowed `missionName`, `status`. Default order is ascending. Prefix with `-` for descending order e.g. `-missionName`.",
3875+
"required": false,
3876+
"type": "string"
3877+
}
3878+
],
3879+
"responses": {
3880+
"200": {
3881+
"description": "Successful operation",
3882+
"schema": {
3883+
"type": "object",
3884+
"properties": {
3885+
"total": {
3886+
"type": "integer"
3887+
},
3888+
"items": {
3889+
"type": "array",
3890+
"items": {
3891+
"type": "object",
3892+
"properties": {
3893+
"id": {
3894+
"type": "string"
3895+
},
3896+
"missionName": {
3897+
"type": "string"
3898+
},
3899+
"status": {
3900+
"type": "string"
3901+
}
3902+
}
3903+
}
3904+
}
3905+
}
3906+
}
3907+
},
3908+
"400": {
3909+
"description": "Invalid parameters",
3910+
"schema": {
3911+
"$ref": "#/definitions/ErrorMsg"
3912+
}
3913+
},
3914+
"401": {
3915+
"description": "Anonymous is not allowed to access",
3916+
"schema": {
3917+
"$ref": "#/definitions/ErrorMsg"
3918+
}
3919+
},
3920+
"403": {
3921+
"description": "Non-pilot is not allowed to access",
3922+
"schema": {
3923+
"$ref": "#/definitions/ErrorMsg"
3924+
}
3925+
},
3926+
"500": {
3927+
"description": "Internal server error",
3928+
"schema": {
3929+
"$ref": "#/definitions/ErrorMsg"
3930+
}
3931+
}
3932+
}
3933+
}
3934+
},
3935+
"/pilot/checklist/{id}": {
3936+
"get": {
3937+
"description": "Get the checklist for specified mission. Pilot role only.",
3938+
"tags": [
3939+
"checklist",
3940+
"pilot"
3941+
],
3942+
"security": [
3943+
{
3944+
"Bearer": []
3945+
}
3946+
],
3947+
"parameters": [
3948+
{
3949+
"in": "path",
3950+
"name": "id",
3951+
"type": "string",
3952+
"required": true
3953+
}
3954+
],
3955+
"responses": {
3956+
"200": {
3957+
"description": "Successful operation",
3958+
"schema": {
3959+
"type": "object",
3960+
"properties": {
3961+
"questions": {
3962+
"type": "array",
3963+
"items": {
3964+
"type": "object",
3965+
"properties": {
3966+
"id": {
3967+
"type": "string"
3968+
},
3969+
"text": {
3970+
"type": "string"
3971+
}
3972+
},
3973+
"required": [
3974+
"id",
3975+
"text"
3976+
]
3977+
}
3978+
},
3979+
"missionStatus": {
3980+
"type": "string"
3981+
},
3982+
"missionName": {
3983+
"type": "string"
3984+
},
3985+
"pilotChecklist": {
3986+
"$ref": "#/definitions/PilotChecklist"
3987+
}
3988+
},
3989+
"required": [
3990+
"questions",
3991+
"missionStatus",
3992+
"missionName"
3993+
]
3994+
}
3995+
},
3996+
"400": {
3997+
"description": "Invalid parameters",
3998+
"schema": {
3999+
"$ref": "#/definitions/ErrorMsg"
4000+
}
4001+
},
4002+
"401": {
4003+
"description": "Anonymous is not allowed to access",
4004+
"schema": {
4005+
"$ref": "#/definitions/ErrorMsg"
4006+
}
4007+
},
4008+
"403": {
4009+
"description": "Non-pilot is not allowed to access",
4010+
"schema": {
4011+
"$ref": "#/definitions/ErrorMsg"
4012+
}
4013+
},
4014+
"404": {
4015+
"description": "Not found. Current logged in pilot is not assigned to this mission",
4016+
"schema": {
4017+
"$ref": "#/definitions/ErrorMsg"
4018+
}
4019+
},
4020+
"500": {
4021+
"description": "Internal server error",
4022+
"schema": {
4023+
"$ref": "#/definitions/ErrorMsg"
4024+
}
4025+
}
4026+
}
4027+
},
4028+
"put": {
4029+
"description": "Update the checklist for specified mission. Pilot role only.",
4030+
"tags": [
4031+
"checklist",
4032+
"pilot"
4033+
],
4034+
"security": [
4035+
{
4036+
"Bearer": []
4037+
}
4038+
],
4039+
"parameters": [
4040+
{
4041+
"in": "path",
4042+
"name": "id",
4043+
"type": "string",
4044+
"required": true
4045+
},
4046+
{
4047+
"in": "body",
4048+
"name": "body",
4049+
"description": "checklist answers and load flag if we want to load mission",
4050+
"schema": {
4051+
"type": "object",
4052+
"properties": {
4053+
"answers": {
4054+
"type": "array",
4055+
"items": {
4056+
"$ref": "#/definitions/PilotChecklistAnswer"
4057+
}
4058+
},
4059+
"load": {
4060+
"type": "boolean"
4061+
}
4062+
}
4063+
},
4064+
"required": true
4065+
}
4066+
],
4067+
"responses": {
4068+
"200": {
4069+
"description": "Successful operation",
4070+
"schema": {
4071+
"type": "object",
4072+
"properties": {
4073+
"missionStatus": {
4074+
"type": "string"
4075+
},
4076+
"pilotChecklist": {
4077+
"$ref": "#/definitions/PilotChecklist"
4078+
}
4079+
},
4080+
"required": [
4081+
"missionStatus",
4082+
"pilotChecklist"
4083+
]
4084+
}
4085+
},
4086+
"400": {
4087+
"description": "Invalid parameters",
4088+
"schema": {
4089+
"$ref": "#/definitions/ErrorMsg"
4090+
}
4091+
},
4092+
"401": {
4093+
"description": "Anonymous is not allowed to access",
4094+
"schema": {
4095+
"$ref": "#/definitions/ErrorMsg"
4096+
}
4097+
},
4098+
"403": {
4099+
"description": "Non-pilot is not allowed to access",
4100+
"schema": {
4101+
"$ref": "#/definitions/ErrorMsg"
4102+
}
4103+
},
4104+
"404": {
4105+
"description": "Not found. Current logged in pilot is not assigned to this mission",
4106+
"schema": {
4107+
"$ref": "#/definitions/ErrorMsg"
4108+
}
4109+
},
4110+
"500": {
4111+
"description": "Internal server error",
4112+
"schema": {
4113+
"$ref": "#/definitions/ErrorMsg"
4114+
}
4115+
}
4116+
}
4117+
}
38434118
}
38444119
},
38454120
"definitions": {
@@ -4381,6 +4656,50 @@
43814656
"coordinates"
43824657
]
43834658
},
4659+
"PilotChecklistAnswer": {
4660+
"type": "object",
4661+
"properties": {
4662+
"question": {
4663+
"type": "string"
4664+
},
4665+
"answer": {
4666+
"type": "string",
4667+
"enum": [
4668+
"yes",
4669+
"no",
4670+
"note"
4671+
]
4672+
},
4673+
"note": {
4674+
"type": "string"
4675+
}
4676+
},
4677+
"required": [
4678+
"question"
4679+
]
4680+
},
4681+
"PilotChecklist": {
4682+
"type": "object",
4683+
"properties": {
4684+
"answers": {
4685+
"type": "array",
4686+
"items": {
4687+
"$ref": "#/definitions/PilotChecklistAnswer"
4688+
}
4689+
},
4690+
"user": {
4691+
"type": "string"
4692+
},
4693+
"createdAt": {
4694+
"type": "string",
4695+
"format": "date"
4696+
},
4697+
"updatedAt": {
4698+
"type": "string",
4699+
"format": "date"
4700+
}
4701+
}
4702+
},
43844703
"ErrorMsg": {
43854704
"type": "object",
43864705
"properties": {

swagger.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -2697,11 +2697,14 @@ paths:
26972697
- text
26982698
missionStatus:
26992699
type: string
2700+
missionName:
2701+
type: string
27002702
pilotChecklist:
27012703
$ref: "#/definitions/PilotChecklist"
27022704
required:
27032705
- questions
27042706
- missionStatus
2707+
- missionName
27052708
400:
27062709
description: Invalid parameters
27072710
schema:

0 commit comments

Comments
 (0)