Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] 新增未成立的原因 #192

Merged
merged 3 commits into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions controller/tasksManageController.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ const tasks = {
publishedAt: task.time.publishedAt,
expiredAt: task.time.expiredAt,
status: statusMapping.taskStatusMapping[task.status] || '',
statusReason: task.statusReason || '',
helper: helperName,
poster: posterName,
progressBar: {
Expand Down Expand Up @@ -523,6 +524,7 @@ const tasks = {
{
$set: {
status: 'deleted',
statusReason: '案主自行刪除任務',
helpers: task.helpers.map((helper) => ({
helperId: helper.helperId,
status: 'dropped',
Expand Down Expand Up @@ -1021,8 +1023,10 @@ const tasks = {
taskId: task._id,
createdAt: currentTime,
});
task.status = 'deleted';
await Task.findByIdAndUpdate(task._id, { $set: { status: 'deleted', 'time.updatedAt': Date.now() }});
await Task.findByIdAndUpdate(task._id, { $set: { status: 'deleted',
statusReason: '系統下架已過期任務',
'time.deletedAt': Date.now(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

這邊有需要更新deletedAt嗎?
我以為此欄位是給"user自行刪除"使用的

'time.updatedAt': Date.now() }});
count++;
console.log(count)
}
Expand Down
5 changes: 5 additions & 0 deletions models/taskModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ const taskSchema = new mongoose.Schema({
required: true,
enum: ['draft', 'published', 'unpublished', 'deleted', 'inProgress', 'submitted', 'confirmed', 'completed', 'expired'],
},
statusReason: {
type: String,
required: false,
default: '',
},
title: {
type: String,
required: [true, "Please enter your task's title."],
Expand Down
1 change: 1 addition & 0 deletions swagger-defintion.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ const getTaskDetails = {
publishedAt: '2022-02-15T05:34:56.000Z',
expiredAt: "2023-03-15T02:55:52.574Z",
status: '已完成',
statusReason: '',
helper: '陳瑋宇',
poster: '翁文方',
progressBar: {
Expand Down
4 changes: 4 additions & 0 deletions swagger-output.json
Original file line number Diff line number Diff line change
Expand Up @@ -5320,6 +5320,10 @@
"type": "string",
"example": "已完成"
},
"statusReason": {
"type": "string",
"example": ""
},
"helper": {
"type": "string",
"example": "陳瑋宇"
Expand Down