From 799ab707e507a7419673ec88ae73d672196794e6 Mon Sep 17 00:00:00 2001 From: imcaizheng Date: Tue, 15 Dec 2020 07:02:46 +0800 Subject: [PATCH] fix function `_getAssignedResourceBooking()` --- ...coder-bookings-api.postman_collection.json | 153 +++++++++--------- docs/swagger.yaml | 6 + src/services/ResourceBookingService.js | 46 +++++- src/services/TeamService.js | 19 +-- 4 files changed, 135 insertions(+), 89 deletions(-) diff --git a/docs/Topcoder-bookings-api.postman_collection.json b/docs/Topcoder-bookings-api.postman_collection.json index 113b823a..445f1789 100644 --- a/docs/Topcoder-bookings-api.postman_collection.json +++ b/docs/Topcoder-bookings-api.postman_collection.json @@ -1,6 +1,6 @@ { "info": { - "_postman_id": "5d74e7a7-d744-4176-994a-62a8ac68efef", + "_postman_id": "37d3b6c4-bd34-4219-bd39-d56264e3a3b8", "name": "Topcoder-bookings-api", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" }, @@ -14,7 +14,7 @@ { "listen": "test", "script": { - "id": "eede316e-3a6b-456a-aa23-18a058e9ea49", + "id": "1b2e6f1f-825c-4bd0-b7d9-cb6b300fe3a7", "exec": [ "var data = JSON.parse(responseBody);\r", "postman.setEnvironmentVariable(\"jobId\",data.id);" @@ -59,7 +59,7 @@ { "listen": "test", "script": { - "id": "e400497c-7e5c-43e1-8402-d21e8dd5a903", + "id": "762aaf85-cd76-4c2d-ace8-abe2d11cc03c", "exec": [ "var data = JSON.parse(responseBody);\r", "postman.setEnvironmentVariable(\"jobIdCreatedByM2M\",data.id);" @@ -104,7 +104,7 @@ { "listen": "test", "script": { - "id": "d835a72e-cebb-4a22-8186-838c6a427a6c", + "id": "d2480c94-19e2-4f9d-81d7-4ea8f5af6ded", "exec": [ "var data = JSON.parse(responseBody);\r", "postman.setEnvironmentVariable(\"jobId\",data.id);" @@ -149,7 +149,7 @@ { "listen": "test", "script": { - "id": "f9889f54-be41-49cf-94d4-a4f39043ee41", + "id": "c1832f81-34c7-4d37-960e-69a15e2d5689", "exec": [ "var data = JSON.parse(responseBody);", "postman.setEnvironmentVariable(\"jobIdCreatedByMember\",data.id);" @@ -194,7 +194,7 @@ { "listen": "test", "script": { - "id": "a79f30e7-6491-483d-b016-a6ff9a0cd0b3", + "id": "5950c660-27ba-4594-913e-cf520be9f698", "exec": [ "" ], @@ -238,7 +238,7 @@ { "listen": "test", "script": { - "id": "d0a3307a-ad6a-4123-a1ec-dd0a30fc8b6c", + "id": "927a494c-9a6c-475f-85da-ab902bb754eb", "exec": [ "" ], @@ -982,7 +982,7 @@ { "listen": "test", "script": { - "id": "1cd415d8-f6e3-43d9-812d-68fe3dc5a707", + "id": "55200ddd-727e-40e0-bf14-4bdc71a1b308", "exec": [ "pm.test(\"Status code is 403\", function () {", " pm.response.to.have.status(403);", @@ -1227,7 +1227,7 @@ { "listen": "test", "script": { - "id": "809d595d-b657-4527-90fa-c9396cf9a0ce", + "id": "79d4bdd7-a294-4302-a253-14de0f1cb5ef", "exec": [ "pm.test(\"Status code is 403\", function () {", " pm.response.to.have.status(403);", @@ -1472,7 +1472,7 @@ { "listen": "test", "script": { - "id": "578a12d8-13d7-4557-9e7b-8958ba75191e", + "id": "87ae5a1d-6a2d-4d54-8b15-0b655b26397f", "exec": [ "pm.test(\"Status code is 403\", function () {", " pm.response.to.have.status(403);", @@ -1591,7 +1591,7 @@ { "listen": "test", "script": { - "id": "df26ced2-6c95-4833-9c2e-db07ccb43d90", + "id": "9341ed82-6439-4b25-b3ee-6e68b686d56a", "exec": [ "var data = JSON.parse(responseBody);\r", "postman.setEnvironmentVariable(\"jobCandidateId\",data.id);" @@ -1636,7 +1636,7 @@ { "listen": "test", "script": { - "id": "51ac0814-9cbb-4b5a-81fc-9fa9e8f82131", + "id": "415d5b9c-4670-4bb7-9741-e4e0edeb5938", "exec": [ "var data = JSON.parse(responseBody);\r", "postman.setEnvironmentVariable(\"jobCandidateIdCreatedByM2M\",data.id);" @@ -1681,7 +1681,7 @@ { "listen": "test", "script": { - "id": "e2482a20-1719-4791-ae49-7c2f052510c5", + "id": "f9c06c94-e853-4023-88ec-631853ff4ac5", "exec": [ "var data = JSON.parse(responseBody);\r", "postman.setEnvironmentVariable(\"jobCandidateId\",data.id);" @@ -1726,7 +1726,7 @@ { "listen": "test", "script": { - "id": "7cb7e30a-5afa-469d-bb58-6eec4f51d1c4", + "id": "2cfc4c43-d085-4bfd-9cdb-230c178de1da", "exec": [ "var data = JSON.parse(responseBody);\r", "postman.setEnvironmentVariable(\"jobCandidateId\",data.id);" @@ -1771,7 +1771,7 @@ { "listen": "test", "script": { - "id": "373fb1e4-2f3c-4182-9f8f-342e62be61a9", + "id": "995492fd-7ced-4e2d-bc7c-00cf2a59bd0b", "exec": [ "var data = JSON.parse(responseBody);\r", "postman.setEnvironmentVariable(\"jobCandidateId\",data.id);" @@ -1816,7 +1816,7 @@ { "listen": "test", "script": { - "id": "a79dc990-c63d-442a-9b33-9c2fd70d8391", + "id": "49d67b90-a9d6-49bc-b7c6-29abcade6542", "exec": [ "" ], @@ -2816,7 +2816,7 @@ { "listen": "test", "script": { - "id": "936361be-5be1-47b1-b2e8-453e67302af3", + "id": "94a35722-0d8d-47c2-a784-97efc41bf533", "exec": [ "var data = JSON.parse(responseBody);\r", "postman.setEnvironmentVariable(\"resourceBookingId\",data.id);" @@ -2861,7 +2861,7 @@ { "listen": "test", "script": { - "id": "eb606efa-595d-466f-b41d-8a6d14f5f160", + "id": "7fbc1bd8-fb7f-408a-9c19-1e77233307cc", "exec": [ "var data = JSON.parse(responseBody);\r", "postman.setEnvironmentVariable(\"resourceBookingIdCreatedByM2M\",data.id);" @@ -2906,7 +2906,7 @@ { "listen": "test", "script": { - "id": "177053c5-325e-4663-9918-afba02fd09f3", + "id": "c9823d26-249e-486e-985f-8d301690f846", "exec": [ "var data = JSON.parse(responseBody);\r", "postman.setEnvironmentVariable(\"resourceBookingId\",data.id);" @@ -2951,7 +2951,7 @@ { "listen": "test", "script": { - "id": "5a42e489-1d61-486a-b5ac-4cfd24950338", + "id": "8a9130a3-990b-4b2e-a62b-a632d5a23c1a", "exec": [ "" ], @@ -2995,7 +2995,7 @@ { "listen": "test", "script": { - "id": "25fd464b-ef8b-45b7-ad51-9350469d7e8e", + "id": "b7d9fde8-cfbf-4ec8-a79e-d4729c081054", "exec": [ "" ], @@ -3039,7 +3039,7 @@ { "listen": "test", "script": { - "id": "73138739-2706-4dfa-8ded-7e74de85962e", + "id": "53b7c5a6-b445-45ab-a1a8-95a65b4c6ff6", "exec": [ "" ], @@ -3262,6 +3262,11 @@ "key": "status", "value": "sourcing", "disabled": true + }, + { + "key": "projectIds", + "value": "111, 16705", + "disabled": true } ] } @@ -4318,7 +4323,7 @@ { "listen": "test", "script": { - "id": "2066b7ec-8e67-4dee-b6bf-d39e780af162", + "id": "95ff39b1-a4af-467c-a4db-f6e3bae20ac6", "exec": [ "var data = JSON.parse(responseBody);", "", @@ -4392,7 +4397,7 @@ { "listen": "test", "script": { - "id": "b580af07-2ac9-4166-b695-a0acc28f047a", + "id": "d940642d-4fe5-4163-af08-c1af0f6f6a62", "exec": [ "var data = JSON.parse(responseBody);\r", "\r", @@ -4449,7 +4454,7 @@ { "listen": "test", "script": { - "id": "7600ff0d-60a9-4eac-b962-783d12ec6528", + "id": "85f2c365-809d-4a18-92a8-e75c3b585065", "exec": [ "var data = JSON.parse(responseBody);\r", "\r", @@ -4499,7 +4504,7 @@ { "listen": "test", "script": { - "id": "d4c844ea-c78b-4cad-b8d0-f91d1ef19bd6", + "id": "934eb335-db8f-46de-ac7f-28e9c18ba17b", "exec": [ "var data = JSON.parse(responseBody);\r", "\r", @@ -4549,7 +4554,7 @@ { "listen": "test", "script": { - "id": "25cd6303-d5b8-4c78-b793-fbe85768d68e", + "id": "61a79684-6850-4462-8bcc-919e5d5a4ddc", "exec": [ "var data = JSON.parse(responseBody);\r", "\r", @@ -4599,7 +4604,7 @@ { "listen": "test", "script": { - "id": "6736cab7-df48-4af5-87be-0aee6416d75d", + "id": "895608f9-7c90-451b-8a11-e62d878a35be", "exec": [ "pm.test(\"Successful POST request\", function () {", " pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]);", @@ -4645,7 +4650,7 @@ { "listen": "test", "script": { - "id": "4b912181-560a-4187-b230-440de69d4a74", + "id": "fa39e460-2720-40a6-85e8-17f33c9f59c4", "exec": [ "pm.test(\"Successful POST request\", function () {", " pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]);", @@ -4691,7 +4696,7 @@ { "listen": "test", "script": { - "id": "a7d5916a-6984-466a-a72c-59d767d1fb1d", + "id": "1f9b6a06-15f4-4c02-be41-96e0a6a621d8", "exec": [ "pm.test(\"Successful POST request\", function () {", " pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]);", @@ -4737,7 +4742,7 @@ { "listen": "test", "script": { - "id": "26560e50-5fc7-47fc-a9dc-88052e65b04e", + "id": "f7e96a2d-2237-4c44-81aa-7ee6e5d70f57", "exec": [ "pm.test(\"Successful POST request\", function () {", " pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]);", @@ -4783,7 +4788,7 @@ { "listen": "test", "script": { - "id": "e22ffd91-332d-47f8-a1ae-add1b8e528f4", + "id": "d5317050-01e8-4ae7-b42e-875b99e549ec", "exec": [ "pm.test(\"Successful POST request\", function () {", " pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]);", @@ -4829,7 +4834,7 @@ { "listen": "test", "script": { - "id": "0e54787d-a531-4784-a3e9-15253ac203e0", + "id": "5a1b32ba-240e-4b04-bdd7-5918cf78828b", "exec": [ "pm.test(\"Successful POST request\", function () {", " pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]);", @@ -4875,7 +4880,7 @@ { "listen": "test", "script": { - "id": "9ca4c42f-aa60-43c0-8865-3759642e775e", + "id": "1c8b58dd-c509-46f8-875e-0b4a3fcc8061", "exec": [ "pm.test(\"Successful POST request\", function () {", " pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]);", @@ -4921,7 +4926,7 @@ { "listen": "test", "script": { - "id": "6f75c0bb-c0b1-4eab-8949-c191ec1b304b", + "id": "aa6cf8f8-f245-4c3c-9be1-9ea45bc26e55", "exec": [ "pm.test(\"Successful POST request\", function () {", " pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]);", @@ -4967,7 +4972,7 @@ { "listen": "test", "script": { - "id": "95c4b4a8-c260-4675-a7ff-b8a35348ad80", + "id": "9638d278-99a1-4ee4-b4d0-6685a9cc74fe", "exec": [ "pm.test(\"Successful PATCH request\", function () {", " pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]);", @@ -5014,7 +5019,7 @@ { "listen": "test", "script": { - "id": "6f7cc660-bb1a-4c43-a29a-11f12fbfb5c9", + "id": "873472f5-05bf-43b4-9b07-f4af0c6d4915", "exec": [ "pm.test(\"Successful PATCH request\", function () {", " pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]);", @@ -5061,7 +5066,7 @@ { "listen": "test", "script": { - "id": "bfe73179-6098-41cf-bebc-d7385d57d478", + "id": "771e8bea-6fa4-4fa0-90f1-2ca234828350", "exec": [ "pm.test(\"Successful PATCH request\", function () {", " pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]);", @@ -5115,7 +5120,7 @@ { "listen": "test", "script": { - "id": "41e6556a-11e4-40bb-be17-41d2b286881e", + "id": "a78e2dc4-5d7f-4924-839c-e8091aad22ec", "exec": [ "var data = JSON.parse(responseBody);\r", "\r", @@ -5165,7 +5170,7 @@ { "listen": "test", "script": { - "id": "ea9cc291-3382-46bc-b30d-16d19e334776", + "id": "eae48594-813b-4503-abba-070e364a80ba", "exec": [ "pm.test(\"Successful POST request\", function () {", " pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]);", @@ -5211,7 +5216,7 @@ { "listen": "test", "script": { - "id": "bf84527d-be67-4aba-a24b-4669d75c8644", + "id": "16fcc254-17da-49a5-80a3-ce31102bf706", "exec": [ "pm.test(\"Successful POST request\", function () {", " pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]);", @@ -5257,7 +5262,7 @@ { "listen": "test", "script": { - "id": "d3c18fa5-01a3-42d6-b84c-a97a31c1ceca", + "id": "6cb0885a-d738-4ac7-854e-21bd41f44842", "exec": [ "pm.test(\"Successful POST request\", function () {", " pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]);", @@ -5303,7 +5308,7 @@ { "listen": "test", "script": { - "id": "76ebfb97-90a6-45f6-a0d4-402cbe77a5a8", + "id": "ac5fb0d6-21ef-4738-befd-9d2f6e66e584", "exec": [ "pm.test(\"Successful POST request\", function () {", " pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]);", @@ -5349,7 +5354,7 @@ { "listen": "test", "script": { - "id": "23c32a83-f20c-4a70-a33d-94eb49468d70", + "id": "2ef7ac60-3a4b-4942-b375-2b88650f7c96", "exec": [ "pm.test(\"Successful POST request\", function () {", " pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]);", @@ -5395,7 +5400,7 @@ { "listen": "test", "script": { - "id": "02c6f86d-e2a6-4b32-85d8-753c2ce40ecf", + "id": "8a711f51-b4bb-4887-9fcf-b801a04c6c91", "exec": [ "pm.test(\"Successful POST request\", function () {", " pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]);", @@ -5441,7 +5446,7 @@ { "listen": "test", "script": { - "id": "95933381-82e4-40ec-bbc3-0f888863793c", + "id": "37c04066-59c3-47af-ad7a-1e36c9094fa3", "exec": [ "pm.test(\"Successful POST request\", function () {", " pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]);", @@ -5487,7 +5492,7 @@ { "listen": "test", "script": { - "id": "17e1204b-7282-47d6-9e5c-f3efa268d69d", + "id": "0afd9ed3-96c2-4f23-9d92-1b32c3e1755c", "exec": [ "pm.test(\"Successful POST request\", function () {", " pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]);", @@ -5533,7 +5538,7 @@ { "listen": "test", "script": { - "id": "1fb3860d-bfd3-42fe-b1cb-e3aec43a7068", + "id": "5da6b28e-4b56-435d-a210-0017cc7be308", "exec": [ "pm.test(\"Successful POST request\", function () {", " pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]);", @@ -5579,7 +5584,7 @@ { "listen": "test", "script": { - "id": "65e40a53-7ab1-4295-b55b-67913c66c642", + "id": "46dee70b-402b-4357-9ff7-3df818187e37", "exec": [ "pm.test(\"Successful POST request\", function () {", " pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]);", @@ -5625,7 +5630,7 @@ { "listen": "test", "script": { - "id": "5f2d37dd-94a5-4ff0-b6dd-ba285f820a62", + "id": "87de944c-a2b2-4d85-a22e-3c8547925d58", "exec": [ "var data = JSON.parse(responseBody);\r", "\r", @@ -5675,7 +5680,7 @@ { "listen": "test", "script": { - "id": "012da7ca-70b0-474c-9478-7d5f0896c5ee", + "id": "f86cf427-6864-47a5-85c1-bbd9ccd3f05d", "exec": [ "var data = JSON.parse(responseBody);\r", "\r", @@ -5725,7 +5730,7 @@ { "listen": "test", "script": { - "id": "a802d37f-e1e3-4c28-98f8-f065dcc91c12", + "id": "9e5dbc13-7177-49f3-bee5-5edfa6707682", "exec": [ "var data = JSON.parse(responseBody);\r", "\r", @@ -5775,7 +5780,7 @@ { "listen": "test", "script": { - "id": "23c93c49-59af-4193-bd24-ed7730ac801d", + "id": "59db9e12-5d7a-4696-8ea2-3814a1f7628f", "exec": [ "var data = JSON.parse(responseBody);\r", "\r", @@ -5825,7 +5830,7 @@ { "listen": "test", "script": { - "id": "955cc007-f31f-4ed4-93a7-54c0efd1e0cb", + "id": "964d6667-4ee7-4c7d-a160-193763e75efa", "exec": [ "var data = JSON.parse(responseBody);\r", "\r", @@ -5875,7 +5880,7 @@ { "listen": "test", "script": { - "id": "496e1faf-3ecf-47db-8b9a-56b08958164d", + "id": "1471ca31-c834-486a-b6b5-ebfbd6cff01e", "exec": [ "var data = JSON.parse(responseBody);\r", "\r", @@ -5925,7 +5930,7 @@ { "listen": "test", "script": { - "id": "5696cc95-b1f3-4ef0-88d4-cd2b6f46a7ec", + "id": "7d90244e-0b28-4cc7-bcbb-a0aa6112f203", "exec": [ "var data = JSON.parse(responseBody);\r", "\r", @@ -5975,7 +5980,7 @@ { "listen": "test", "script": { - "id": "85b2f034-a66b-45bb-b6c9-db95e77a08f8", + "id": "28348059-186e-4c7b-ac40-b966999907af", "exec": [ "var data = JSON.parse(responseBody);\r", "\r", @@ -6025,7 +6030,7 @@ { "listen": "test", "script": { - "id": "dcae5aff-6734-4192-9abd-59b91c62f78b", + "id": "e0b243ca-1b31-4619-836f-9d5c8896d8cf", "exec": [ "var data = JSON.parse(responseBody);\r", "\r", @@ -6075,7 +6080,7 @@ { "listen": "test", "script": { - "id": "002e4a7e-4d0f-48f6-95ee-e3daf81431aa", + "id": "9d5d7c9e-3c85-4c68-8906-22200b1e653a", "exec": [ "var data = JSON.parse(responseBody);\r", "\r", @@ -6125,7 +6130,7 @@ { "listen": "test", "script": { - "id": "7791a3df-da95-440e-8b59-91dc7918fb9e", + "id": "e7b2b625-81ff-4c21-9a41-0db5ab0d102c", "exec": [ "pm.test(\"Successful PATCH request\", function () {", " pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]);", @@ -6172,7 +6177,7 @@ { "listen": "test", "script": { - "id": "2c44579b-d9d3-405b-b265-ea73c35128ed", + "id": "29389fdd-08e2-4a69-be29-4c0346401322", "exec": [ "pm.test(\"Successful PATCH request\", function () {", " pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]);", @@ -6219,7 +6224,7 @@ { "listen": "test", "script": { - "id": "49ab91cd-f5d4-44a9-823c-7980d8d8e896", + "id": "cdf1871e-ecea-4148-814b-dc585578fa77", "exec": [ "pm.test(\"Successful PATCH request\", function () {", " pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]);", @@ -6266,7 +6271,7 @@ { "listen": "test", "script": { - "id": "ba45ce14-076d-4bc6-8e95-4bd7db32a9bc", + "id": "69154f22-4c76-4e74-ba9d-5738fc77701c", "exec": [ "pm.test(\"Successful PATCH request\", function () {", " pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]);", @@ -6313,7 +6318,7 @@ { "listen": "test", "script": { - "id": "3a57e69b-a02c-4cca-b225-11d7fa4e780d", + "id": "6959f008-3278-4a5f-9751-ca5fa95d6611", "exec": [ "pm.test(\"Successful PATCH request\", function () {", " pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]);", @@ -6360,7 +6365,7 @@ { "listen": "test", "script": { - "id": "da3d9d7d-fd9a-41de-9378-840e34f01d8d", + "id": "3201f89a-6383-4beb-8952-e81307a735cd", "exec": [ "pm.test(\"Successful PATCH request\", function () {", " pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]);", @@ -6407,7 +6412,7 @@ { "listen": "test", "script": { - "id": "67d7211b-2d23-47e0-8fad-b9725221c17e", + "id": "1aea95ac-5586-44f7-a8ba-4c5cb5db96cd", "exec": [ "pm.test(\"Successful PATCH request\", function () {", " pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]);", @@ -6454,7 +6459,7 @@ { "listen": "test", "script": { - "id": "124fe3ee-0314-4da3-b564-da848d11d1a6", + "id": "58fe8e95-7c6c-46c8-b851-5ef2cce629c0", "exec": [ "pm.test(\"Successful PATCH request\", function () {", " pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]);", @@ -6501,7 +6506,7 @@ { "listen": "test", "script": { - "id": "fd8103a8-3369-429d-8ba0-a46c3b7b1f04", + "id": "a345e774-d2b6-4073-95f7-7f64aba91940", "exec": [ "pm.test(\"Successful PATCH request\", function () {", " pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]);", @@ -6548,7 +6553,7 @@ { "listen": "test", "script": { - "id": "cbc8fa49-6f36-461b-b1a9-70dd3b82572e", + "id": "456b01cd-71a4-4106-97f8-031071cbd30e", "exec": [ "pm.test(\"Successful PATCH request\", function () {", " pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]);", @@ -6595,7 +6600,7 @@ { "listen": "test", "script": { - "id": "ace9e189-c5f8-4eab-931b-3714f9e37260", + "id": "1ef3d1a5-d223-492a-bce1-b6a56686b63a", "exec": [ "pm.test(\"Successful PATCH request\", function () {", " pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]);", @@ -6649,7 +6654,7 @@ { "listen": "test", "script": { - "id": "c7fb7228-ca43-4cef-804a-23c25e9df21e", + "id": "8e8310d3-9d9f-4740-9fcc-b0453639f618", "exec": [ "var data = JSON.parse(responseBody);\r", "\r", @@ -6699,7 +6704,7 @@ { "listen": "test", "script": { - "id": "67892217-b9e9-4b20-947d-df49d8a0f855", + "id": "7d530291-663e-4066-bc2e-1ba7d75932ce", "exec": [ "pm.test(\"Successful PATCH request\", function () {", " pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]);", @@ -6753,7 +6758,7 @@ { "listen": "test", "script": { - "id": "db632f9d-a83b-42f7-861b-da3ded160f45", + "id": "cc1f0be0-698f-46e1-a704-54905c9dbd24", "exec": [ "var data = JSON.parse(responseBody);\r", "\r", @@ -6803,7 +6808,7 @@ { "listen": "test", "script": { - "id": "73d2a47b-47d8-4681-b9dc-905d987b4ca9", + "id": "43846e9f-cc3f-4922-9d90-ca6b4f9de0ad", "exec": [ "pm.test(\"Successful PATCH request\", function () {", " pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]);", diff --git a/docs/swagger.yaml b/docs/swagger.yaml index a35dc19b..a1a28533 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -107,6 +107,12 @@ paths: schema: type: integer description: The project id. + - in: query + name: projectIds + required: false + schema: + type: string + description: The project ids, separated by commas. - in: query name: externalId required: false diff --git a/src/services/ResourceBookingService.js b/src/services/ResourceBookingService.js index cf6a74f9..95556dab 100644 --- a/src/services/ResourceBookingService.js +++ b/src/services/ResourceBookingService.js @@ -228,11 +228,33 @@ deleteResourceBooking.schema = Joi.object().keys({ /** * List resourceBookings * @params {Object} criteria the search criteria + * @params {Object} options the extra options to control the function * @returns {Object} the search result, contain total/page/perPage and result array */ -async function searchResourceBookings (criteria) { +async function searchResourceBookings (criteria, options = { returnAll: false }) { + if (criteria.projectIds) { + if ((typeof criteria.projectIds) === 'string') { + criteria.projectIds = criteria.projectIds.trim().split(',').map(projectIdRaw => { + const projectIdRawTrimed = projectIdRaw.trim() + const projectId = Number(projectIdRawTrimed) + if (_.isNaN(projectId)) { + throw new errors.BadRequestError(`projectId ${projectIdRawTrimed} is not a valid number`) + } + return projectId + }) + } + } const page = criteria.page > 0 ? criteria.page : 1 - const perPage = criteria.perPage > 0 ? criteria.perPage : 20 + let perPage + if (options.returnAll) { + // To simplify the logic we are use a very large number for perPage + // because in practice there could hardly be so many records to be returned.(also consider we are using filters in the meantime) + // the number is limited by `index.max_result_window`, its default value is 10000, see + // https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules.html#index-max-result-window + perPage = 10000 + } else { + perPage = criteria.perPage > 0 ? criteria.perPage : 20 + } if (!criteria.sortBy) { criteria.sortBy = 'id' @@ -266,6 +288,14 @@ async function searchResourceBookings (criteria) { } }) }) + // if criteria contains projectIds, filter projectId with this value + if (criteria.projectIds) { + esQuery.body.query.bool.filter = [{ + terms: { + projectId: criteria.projectIds + } + }] + } logger.debug({ component: 'ResourceBookingService', context: 'searchResourceBookings', message: `Query: ${JSON.stringify(esQuery)}` }) const { body } = await esClient.search(esQuery) @@ -290,6 +320,9 @@ async function searchResourceBookings (criteria) { _.each(_.pick(criteria, ['status', 'startDate', 'endDate', 'rateType']), (value, key) => { filter[Op.and].push({ [key]: value }) }) + if (criteria.projectIds) { + filter[Op.and].push({ projectId: criteria.projectIds }) + } const resourceBookings = await ResourceBooking.findAll({ where: filter, attributes: { @@ -318,8 +351,13 @@ searchResourceBookings.schema = Joi.object().keys({ startDate: Joi.date(), endDate: Joi.date(), rateType: Joi.rateType(), - projectId: Joi.number().integer() - }).required() + projectId: Joi.number().integer(), + projectIds: Joi.alternatives( + Joi.string(), + Joi.array().items(Joi.number().integer()) + ) + }).required(), + options: Joi.object() }).required() module.exports = { diff --git a/src/services/TeamService.js b/src/services/TeamService.js index 64a3aad5..4fd3ab6a 100644 --- a/src/services/TeamService.js +++ b/src/services/TeamService.js @@ -11,16 +11,13 @@ const JobService = require('./JobService') const ResourceBookingService = require('./ResourceBookingService') /** - * Function to get assigned resource booking - * @param {String} projectId project id + * Function to get assigned resource bookings with specific projectIds + * @param {Array} projectIds project ids * @returns the request result */ -async function _getAssignedResourceBooking (projectId) { - const criteria = { status: 'assigned' } - if (projectId) { - criteria.projectId = projectId - } - const { result } = await ResourceBookingService.searchResourceBookings(criteria) +async function _getAssignedResourceBookingsByProjectIds (projectIds) { + const criteria = { status: 'assigned', projectIds } + const { result } = await ResourceBookingService.searchResourceBookings(criteria, { returnAll: true }) return result } @@ -88,9 +85,9 @@ searchTeams.schema = Joi.object().keys({ */ async function getTeamDetail (currentUser, projects, isSearch = true) { const projectIds = _.map(projects, 'id') - // Get resourceBookings from taas api - const resourceBookings = await _getAssignedResourceBooking() - // Get jobs from taas api + // Get all assigned resourceBookings filtered by projectIds + const resourceBookings = await _getAssignedResourceBookingsByProjectIds(projectIds) + // Get all jobs filtered by projectIds const jobs = await _getJobsByProjectIds(projectIds) // Get first week day and last week day