mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 06:37:23 +01:00
Feature - Store Exact Completion Date For Dailies (#9813)
* dailies history date added in scoreTask instead of cron * fix lint issues * changes based on feedback. Undo cron code deletion and deleted iteration on scoreTask * fix lint issues * add task history entry in cron for dailies that weren't completed * add history entry after value is fully evaluated
This commit is contained in:
committed by
Matteo Pagliazzi
parent
fbacb56700
commit
a61d911c48
@@ -243,11 +243,24 @@ module.exports = function scoreTask (options = {}, req = {}) {
|
||||
if (user.addNotification) user.addNotification('STREAK_ACHIEVEMENT');
|
||||
}
|
||||
task.completed = true;
|
||||
|
||||
// Save history entry for daily
|
||||
task.history = task.history || [];
|
||||
let historyEntry = {
|
||||
date: Number(new Date()),
|
||||
value: task.value,
|
||||
};
|
||||
task.history.push(historyEntry);
|
||||
} else if (direction === 'down') {
|
||||
// Remove a streak achievement if streak was a multiple of 21 and the daily was undone
|
||||
if (task.streak !== 0 && task.streak % 21 === 0) user.achievements.streak = user.achievements.streak ? user.achievements.streak - 1 : 0;
|
||||
task.streak -= 1;
|
||||
task.completed = false;
|
||||
|
||||
// Delete history entry when daily unchecked
|
||||
if (task.history || task.history.length > 0) {
|
||||
task.history.splice(-1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (task.type === 'todo') {
|
||||
|
||||
Reference in New Issue
Block a user