Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
When Meet - Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
websystem2023-2
When Meet - Backend
Commits
e24736b7
Commit
e24736b7
authored
1 year ago
by
Wo-ogie
Browse files
Options
Downloads
Patches
Plain Diff
fix: scheduled job에서 에러가 발생할 경우 서버가 종료되는 문제 수정
parent
1b1d5b20
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
controllers/meeting.js
+11
-3
11 additions, 3 deletions
controllers/meeting.js
schedules/checkMeetings.js
+2
-2
2 additions, 2 deletions
schedules/checkMeetings.js
services/meeting.js
+6
-9
6 additions, 9 deletions
services/meeting.js
with
19 additions
and
14 deletions
controllers/meeting.js
+
11
−
3
View file @
e24736b7
...
@@ -8,11 +8,12 @@ const {
...
@@ -8,11 +8,12 @@ const {
getMeetingWithParticipantsById
,
getMeetingWithParticipantsById
,
getMeetingWithParticipantsAndSchedulesById
,
getMeetingWithParticipantsAndSchedulesById
,
getNumOfParticipantsByMeetingId
,
getNumOfParticipantsByMeetingId
,
clo
seMeeting
ById
,
se
t
Meeting
ClosedAndSendVoteEndEmail
,
}
=
require
(
'
../services/meeting
'
);
}
=
require
(
'
../services/meeting
'
);
const
{
const
{
createPasswordNotMatchedError
,
createPasswordNotMatchedError
,
createPasswordIsNullError
,
createPasswordIsNullError
,
createMeetingIsAlreadyClosedError
,
}
=
require
(
'
../errors/meetingErrors
'
);
}
=
require
(
'
../errors/meetingErrors
'
);
const
MeetingResponse
=
require
(
'
../dto/response/meetingResponse
'
);
const
MeetingResponse
=
require
(
'
../dto/response/meetingResponse
'
);
const
MeetingWithParticipantsResponse
=
require
(
'
../dto/response/meetingWithParticipantsResponse
'
);
const
MeetingWithParticipantsResponse
=
require
(
'
../dto/response/meetingWithParticipantsResponse
'
);
...
@@ -84,7 +85,7 @@ exports.createMeeting = async (req, res, next) => {
...
@@ -84,7 +85,7 @@ exports.createMeeting = async (req, res, next) => {
});
});
schedule
.
scheduleJob
(
meeting
.
voteExpiresAt
,
async
()
=>
{
schedule
.
scheduleJob
(
meeting
.
voteExpiresAt
,
async
()
=>
{
await
clo
seMeeting
ById
(
meeting
.
id
);
await
se
t
Meeting
ClosedAndSendVoteEndEmail
(
meeting
.
id
);
});
});
return
res
.
status
(
201
).
json
(
MeetingResponse
.
from
(
meeting
));
return
res
.
status
(
201
).
json
(
MeetingResponse
.
from
(
meeting
));
...
@@ -163,6 +164,12 @@ exports.getTopThreeConfirmedTimes = async (req, res, next) => {
...
@@ -163,6 +164,12 @@ exports.getTopThreeConfirmedTimes = async (req, res, next) => {
}
}
};
};
function
validateMeetingIsNotClosed
(
meeting
)
{
if
(
meeting
.
isClosed
===
true
)
{
throw
createMeetingIsAlreadyClosedError
();
}
}
exports
.
closeMeeting
=
async
(
req
,
res
,
next
)
=>
{
exports
.
closeMeeting
=
async
(
req
,
res
,
next
)
=>
{
try
{
try
{
// TODO: query 최적화 필요
// TODO: query 최적화 필요
...
@@ -173,8 +180,9 @@ exports.closeMeeting = async (req, res, next) => {
...
@@ -173,8 +180,9 @@ exports.closeMeeting = async (req, res, next) => {
req
.
body
.
adminPassword
,
req
.
body
.
adminPassword
,
meeting
.
adminPassword
,
meeting
.
adminPassword
,
);
);
validateMeetingIsNotClosed
(
meeting
);
await
clo
seMeeting
ById
(
meetingId
);
await
se
t
Meeting
ClosedAndSendVoteEndEmail
(
meetingId
);
meeting
=
await
getMeetingWithParticipantsById
(
meetingId
);
meeting
=
await
getMeetingWithParticipantsById
(
meetingId
);
return
res
.
json
(
MeetingResponse
.
from
(
meeting
));
return
res
.
json
(
MeetingResponse
.
from
(
meeting
));
...
...
This diff is collapsed.
Click to expand it.
schedules/checkMeetings.js
+
2
−
2
View file @
e24736b7
const
{
scheduleJob
}
=
require
(
'
node-schedule
'
);
const
{
scheduleJob
}
=
require
(
'
node-schedule
'
);
const
{
Op
}
=
require
(
'
sequelize
'
);
const
{
Op
}
=
require
(
'
sequelize
'
);
const
{
Meeting
}
=
require
(
'
../models
'
);
const
{
Meeting
}
=
require
(
'
../models
'
);
const
{
clo
seMeeting
ById
}
=
require
(
'
../services/meeting
'
);
const
{
se
t
Meeting
ClosedAndSendVoteEndEmail
}
=
require
(
'
../services/meeting
'
);
module
.
exports
=
async
()
=>
{
module
.
exports
=
async
()
=>
{
console
.
log
(
console
.
log
(
...
@@ -18,7 +18,7 @@ module.exports = async () => {
...
@@ -18,7 +18,7 @@ module.exports = async () => {
});
});
meetings
.
forEach
((
meeting
)
=>
{
meetings
.
forEach
((
meeting
)
=>
{
scheduleJob
(
meeting
.
voteExpiresAt
,
async
()
=>
{
scheduleJob
(
meeting
.
voteExpiresAt
,
async
()
=>
{
await
clo
seMeeting
ById
(
meeting
.
id
);
await
se
t
Meeting
ClosedAndSendVoteEndEmail
(
meeting
.
id
);
});
});
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
...
...
This diff is collapsed.
Click to expand it.
services/meeting.js
+
6
−
9
View file @
e24736b7
...
@@ -57,15 +57,12 @@ const getNumOfParticipantsByMeetingId = async (meetingId) =>
...
@@ -57,15 +57,12 @@ const getNumOfParticipantsByMeetingId = async (meetingId) =>
},
},
});
});
function
validateMeetingIsNotClosed
(
meeting
)
{
const
setMeetingClosedAndSendVoteEndEmail
=
async
(
meetingId
)
=>
{
if
(
meeting
.
isClosed
===
true
)
{
throw
createMeetingIsAlreadyClosedError
();
}
}
const
closeMeetingById
=
async
(
meetingId
)
=>
{
const
meeting
=
await
getMeetingWithParticipantsById
(
meetingId
);
const
meeting
=
await
getMeetingWithParticipantsById
(
meetingId
);
validateMeetingIsNotClosed
(
meeting
);
if
(
meeting
.
isClosed
)
{
return
;
}
meeting
.
isClosed
=
true
;
meeting
.
isClosed
=
true
;
await
meeting
.
save
();
await
meeting
.
save
();
...
@@ -83,5 +80,5 @@ module.exports = {
...
@@ -83,5 +80,5 @@ module.exports = {
getMeetingWithParticipantsById
,
getMeetingWithParticipantsById
,
getMeetingWithParticipantsAndSchedulesById
,
getMeetingWithParticipantsAndSchedulesById
,
getNumOfParticipantsByMeetingId
,
getNumOfParticipantsByMeetingId
,
clo
seMeeting
ById
,
se
t
Meeting
ClosedAndSendVoteEndEmail
,
};
};
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment