@@ -21,13 +21,22 @@ const uncompletedMission = async (memberId) => {
2121 } ,
2222 } ) ;
2323
24- const uncompletedMissionList = [ ] ;
25- const completedMissionList = [ ] ;
24+ const missionList = [ ] ;
2625
2726 for ( const mission of missions ) {
2827 const currentValue = await missionUtils . calculateCurrentValue ( memberId , mission ) ;
2928 const completed = currentValue >= mission . mission . targetValue ;
3029
30+ const formatMission = {
31+ title : mission . mission . title ,
32+ description : mission . mission . description ,
33+ type : mission . mission . type ,
34+ targetValue : mission . mission . targetValue ,
35+ currentValue : currentValue ,
36+ completed,
37+ flowerName : mission . mission . flower . name ,
38+ } ;
39+
3140 //완료된 미션
3241 if ( completed ) {
3342 //완료처리
@@ -39,31 +48,11 @@ const uncompletedMission = async (memberId) => {
3948 } ,
4049 } ) ;
4150 //꽃 해제
42- missionUtils . unlockFlower ( memberId , mission . mission . flower . id ) ;
43-
44- completedMissionList . push ( {
45- missionId : mission . id ,
46- flower : mission . mission . flower ?
47- {
48- name : mission . mission . flower . name ,
49- FlowerImg : mission . mission . flower . FlowerImg
50- } : null
51- } ) ;
52- } else {
53- //완료X미션
54- const formatMission = {
55- title : mission . mission . title ,
56- description : mission . mission . description ,
57- type : mission . mission . type ,
58- targetValue : mission . mission . targetValue ,
59- currentValue : currentValue ,
60- completed,
61- flowerName : mission . mission . flower . name ,
62- } ;
63-
64- uncompletedMissionList . push ( formatMission ) ;
65- } }
66- return { completedMissions : completedMissionList , uncompletedMissions : uncompletedMissionList } ;
51+ await missionUtils . unlockFlower ( memberId , mission . mission . flower . id ) ;
52+ }
53+ missionList . push ( formatMission ) ;
54+ }
55+ return { missionList } ;
6756 } catch ( error ) {
6857 console . error ( error ) ;
6958 throw new CustomError ( ErrorCodes . InternalServerError , "사용자의 미션 목록 조회 중 오류가 발생하였습니다." ) ;
@@ -121,7 +110,7 @@ const updateConsecutivePlantingMission = async(memberId) => {
121110 lastUpdated : today ,
122111 } ,
123112 } ) ;
124- missionUtils . unlockFlower ( memberId , plantingMission . mission . flower . id ) ;
113+ await missionUtils . unlockFlower ( memberId , plantingMission . mission . flower . id ) ;
125114 completedMissions . push ( {
126115 missionId : plantingMission . id ,
127116 flower : plantingMission . mission . flower ?
@@ -173,7 +162,7 @@ const updateFocusTimeMission = async(memberId) => {
173162 where : { id : focusMission . id } ,
174163 data : { completed : true } ,
175164 } ) ;
176- missionUtils . unlockFlower ( memberId , focusMission . mission . flower . id ) ;
165+ await missionUtils . unlockFlower ( memberId , focusMission . mission . flower . id ) ;
177166 completedMissions . push ( {
178167 missionId : focusMission . id ,
179168 flower : focusMission . mission . flower ?
@@ -213,7 +202,7 @@ const updateTotalFlowerMission = async(memberId) => {
213202 where : { id : flowerMission . id } ,
214203 data : { completed : true } ,
215204 } ) ;
216- missionUtils . unlockFlower ( memberId , flowerMission . mission . flower . id ) ;
205+ await missionUtils . unlockFlower ( memberId , flowerMission . mission . flower . id ) ;
217206 completedMissions . push ( {
218207 missionId : flowerMission . id ,
219208 flower : flowerMission . mission . flower ?
@@ -267,4 +256,4 @@ module.exports = {
267256 updateTotalFlowerMission,
268257 updateFocusTimeMission,
269258 setupMission,
270- }
259+ }
0 commit comments