fix some bug

This commit is contained in:
CounterFire2023 2024-01-03 19:25:57 +08:00
parent e9b0f802c1
commit 2b5ae26454
4 changed files with 13 additions and 7 deletions

View File

@ -8,27 +8,30 @@
"title": "Connect Twitter",
"type": 1,
"desc": "",
"score": 100,
"category": "",
"autoclaim": true,
"params": {"score": 100}
"params": {}
}, {
"id": "TwitterFollow",
"title": "Follow Twitter",
"type": 1,
"desc": "",
"category": "",
"score": 100,
"autoclaim": false,
"pretasks": ["TwitterConnect"],
"params": {"score": 100, "time": 6, "failRate": 60}
"params": {"time": 6, "failRate": 60}
}, {
"id": "TwitterRetweet",
"title": "ReTwitt",
"type": 2,
"desc": "",
"category": "",
"score": 100,
"autoclaim": false,
"pretasks": ["TwitterConnect"],
"params": {"score": 100, "time": 6, "failRate": 60}
"params": {"time": 6, "failRate": 60}
}, {
"id": "UpdateScore",
"type": 1,

View File

@ -76,7 +76,7 @@ export default class TasksController extends BaseController {
let { task } = req.params;
const [taskId, dateTag] = task.split(':');
const currentDateTag = formatDate(new Date());
if (currentDateTag !== dateTag) {
if (dateTag && currentDateTag !== dateTag) {
throw new ZError(11, 'task date not match')
}
let cfg = activity.tasks.find((t: TaskCfg) => t.id === taskId);
@ -118,7 +118,7 @@ export default class TasksController extends BaseController {
const { task } = req.params;
const [taskId, dateTag] = task.split(':');
const currentDateTag = formatDate(new Date());
if (currentDateTag !== dateTag) {
if (dateTag && currentDateTag !== dateTag) {
throw new ZError(11, 'task date not match')
}
let currentTask = user.taskProgress.find((t: TaskStatus) => t.id === task);

View File

@ -18,6 +18,9 @@ export abstract class ITask {
const user = this.params.user
const [taskId, dateTag] = task.id.split(':');
const cfg = this.params.activity.tasks.find((t: TaskCfg) => t.id === taskId)
if (!cfg.score) {
return;
}
await updateRankScore({
user: user.id,
score: cfg.score,

View File

@ -1,7 +1,7 @@
// format the date to the format we want
export const formatDate = (date: Date): string => {
const year = date.getFullYear();
const month = date.getMonth() + 1;
const day = date.getDate();
const month = (date.getMonth() + 1 + '').padStart(2, '0');
const day = (date.getDate() + '').padStart(2, '0');
return `${year}${month}${day}`;
};