From cdb439d3cd71eebd5825151f2d6ec0135d95e5cd Mon Sep 17 00:00:00 2001 From: mumtazbukuru <70026185+mumtazbukuru@users.noreply.github.com> Date: Sat, 19 Oct 2024 10:21:17 +0100 Subject: [PATCH 1/2] Removed unused properties from TaskItem as per issue #2065 --- src/models/TaskItem.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/models/TaskItem.ts b/src/models/TaskItem.ts index 5973e2b27..014ba4649 100644 --- a/src/models/TaskItem.ts +++ b/src/models/TaskItem.ts @@ -8,12 +8,6 @@ export interface TaskItem { id: string; goalId: string; title: string; - hoursSpent: number; - completedToday: number; - completedTodayIds: string[]; - skippedToday: string[]; - lastCompleted: string; // date - lastSkipped: string; // date blockedSlots: blockedSlotOfTask[]; completedTodayTimings: TCompletedTaskTiming[]; // to store timings of the tasks that are completed today } From 54e4455cd82eaf0fe2d0d7ade8e77e0d5206b324 Mon Sep 17 00:00:00 2001 From: mumtazbukuru <70026185+mumtazbukuru@users.noreply.github.com> Date: Sun, 20 Oct 2024 11:18:58 +0100 Subject: [PATCH 2/2] Removed references to unused TaskItem properties and updated related code --- src/Interfaces/IScheduler.ts | 2 - src/api/TasksAPI/index.ts | 42 +------------------ .../MyTimeline/MyTimeline.tsx | 8 ---- src/helpers/MyTimeHelper.ts | 5 --- src/models/dexie.ts | 6 +-- src/utils/rawDBScript.js | 3 -- 6 files changed, 2 insertions(+), 64 deletions(-) diff --git a/src/Interfaces/IScheduler.ts b/src/Interfaces/IScheduler.ts index cba5d7cb9..27289fffd 100644 --- a/src/Interfaces/IScheduler.ts +++ b/src/Interfaces/IScheduler.ts @@ -54,8 +54,6 @@ export interface ISchedulerInputGoal { }; children?: string[]; createdAt: string; - hoursSpent?: number; - skippedToday?: string[]; } export interface ISchedulerOutputGoal { diff --git a/src/api/TasksAPI/index.ts b/src/api/TasksAPI/index.ts index a041cde00..dc5e42a38 100644 --- a/src/api/TasksAPI/index.ts +++ b/src/api/TasksAPI/index.ts @@ -29,26 +29,12 @@ export const getTaskByGoalId = async (goalId: string) => { } }; -export const getForgetHrsCount = (task: TaskItem) => { - let yesterdaysCount = 0; - task.skippedToday.forEach((slot) => { - const [start, end] = slot.split("-"); - yesterdaysCount += Number(end) - Number(start); - }); - return yesterdaysCount; -}; - export const resetProgressOfToday = async () => { const tasks = await db.taskCollection.toArray(); try { await db.transaction("rw", db.taskCollection, async () => { const updatedRows = tasks.map((_task) => { const task = { ..._task }; - task.completedToday = 0; - task.completedTodayIds = []; - task.skippedToday = []; - task.lastCompleted = new Date().toLocaleDateString(); - task.lastSkipped = new Date().toLocaleDateString(); task.blockedSlots = []; return task; }); @@ -74,28 +60,8 @@ export const refreshTaskCollection = async () => { const updatedRows = tasks.map((_task) => { const task = { ..._task }; const goal: GoalItem = goals[task.goalId]; - const startDate = new Date(goal.start || goal.createdAt); - if (goal.habit === "daily") { - task.hoursSpent = 0; - } else if (goal.habit === "weekly") { - const dayIndex = calDays.indexOf(convertDateToDay(startDate)); - const lastReset = getLastDayDate(dayIndex); - const lastAction = new Date( - new Date(task.lastSkipped) < new Date(task.lastCompleted) ? task.lastCompleted : task.lastSkipped, - ); - if (lastAction < lastReset) { - task.hoursSpent = 0; - } else { - task.hoursSpent += task.completedToday + getForgetHrsCount(task); - } - } else { - task.hoursSpent += task.completedToday + getForgetHrsCount(task); + if (goal.habit === "weekly") { } - task.completedToday = 0; - task.completedTodayIds = []; - task.skippedToday = []; - task.lastCompleted = new Date().toLocaleDateString(); - task.lastSkipped = new Date().toLocaleDateString(); return task; }); @@ -112,13 +78,11 @@ export const completeTask = async (id: string, duration: number, task: ITask) => .where("id") .equals(id) .modify((obj: TaskItem) => { - obj.completedToday += duration; obj.completedTodayTimings.push({ goalid: task.goalid, start: task.start, deadline: task.deadline, }); - obj.completedTodayIds.push(task.taskid); }); }).catch((e) => { console.log(e.stack || e); @@ -131,15 +95,11 @@ export const skipTask = async (id: string, period: string, task: ITask) => { .where("id") .equals(id) .modify((obj: TaskItem) => { - obj.skippedToday.push(period); obj.completedTodayTimings.push({ goalid: task.goalid, start: task.start, deadline: task.deadline, }); - if (obj.skippedToday.length > 1) { - obj.skippedToday.sort((a, b) => Number(a.split("-")[0]) - Number(b.split("-")[0])); - } }); }).catch((e) => { console.log(e.stack || e); diff --git a/src/components/MyTimeComponents/MyTimeline/MyTimeline.tsx b/src/components/MyTimeComponents/MyTimeline/MyTimeline.tsx index 3729a26a8..a7cc2dbd3 100644 --- a/src/components/MyTimeComponents/MyTimeline/MyTimeline.tsx +++ b/src/components/MyTimeComponents/MyTimeline/MyTimeline.tsx @@ -105,12 +105,6 @@ export const MyTimeline: React.FC = ({ day, myTasks, taskDetail id: uuidv4(), goalId: task.goalid, title: task.title, - completedTodayIds: [], - skippedToday: [], - completedToday: actionName === TaskAction.Done ? Number(task.duration) : 0, - lastSkipped: "", - lastCompleted: actionName === TaskAction.Done ? new Date().toLocaleDateString() : "", - hoursSpent: 0, completedTodayTimings: actionName === TaskAction.Done ? [ @@ -124,8 +118,6 @@ export const MyTimeline: React.FC = ({ day, myTasks, taskDetail blockedSlots: [], }); } else if (actionName === TaskAction.Done) { - const markDone = !!taskDetails[task.goalid]?.completedTodayIds.includes(task.taskid); - if (markDone) return null; await completeTask(taskItem.id, Number(task.duration), task); } else if (actionName === TaskAction.NotNow) { setOpenReschedule(task); diff --git a/src/helpers/MyTimeHelper.ts b/src/helpers/MyTimeHelper.ts index db87668eb..b91284a15 100644 --- a/src/helpers/MyTimeHelper.ts +++ b/src/helpers/MyTimeHelper.ts @@ -24,8 +24,6 @@ export const transformIntoSchInputGoals = ( activeGoals.forEach(async (ele) => { const obj: ISchedulerInputGoal = { id: ele.id, title: t(ele.title), filters: {}, createdAt: ele.createdAt }; const slotsNotallowed = blockedSlots[ele.id]; - // obj.hoursSpent = dbTasks[ele.id]?.hoursSpent || 0; - // obj.skippedToday = dbTasks[ele.id]?.skippedToday || []; if (ele.duration) obj.minDuration = Number(ele.duration); if (ele.start) { obj.start = convertDateToString(new Date(ele.start)); @@ -154,9 +152,6 @@ export const organizeDataForInptPrep = async (inputGoals: GoalItem[]) => { const startDate = convertDateToString(new Date(_today)); const endDate = convertDateToString(new Date(_today.setDate(_today.getDate() + 7))); const tasksCompletedToday: TCompletedTaskTiming[] = []; - getAllTasks().then((docs) => - docs.filter((doc) => doc.completedToday > 0).map((doc) => tasksCompletedToday.push(...doc.completedTodayTimings)), - ); const schedulerInput: ISchedulerInput = { startDate, diff --git a/src/models/dexie.ts b/src/models/dexie.ts index 423927085..30ffa16b8 100644 --- a/src/models/dexie.ts +++ b/src/models/dexie.ts @@ -15,8 +15,7 @@ export const dbStoreSchema = { inboxCollection: "id, goalChanges", pubSubCollection: "id, subscribers", publicGroupsCollection: null, - taskCollection: - "id, goalId, title, hoursSpent, completedTodayIds, completedTodayTimings, lastCompleted, lastSkipped, blockedSlots, skippedToday, completedToday", + taskCollection: "id, goalId, title, completedTodayTimings, blockedSlots", customizationCollection: "++id, goalId, posIndex", dumpboxCollection: "id, key, value", partnersCollection: null, @@ -46,9 +45,6 @@ export const syncVersion = (transaction: Transaction, currentVersion: number) => const taskCollection = transaction.table("taskCollection"); taskCollection.toCollection().modify((task: TaskItem) => { task.blockedSlots = []; - task.skippedToday = []; - task.completedToday = 0; - task.completedTodayIds = []; }); } if (currentVersion < 12) { diff --git a/src/utils/rawDBScript.js b/src/utils/rawDBScript.js index feb118d8a..d4ea5f3ff 100644 --- a/src/utils/rawDBScript.js +++ b/src/utils/rawDBScript.js @@ -13,9 +13,6 @@ // const data = event.target.result; // // Modify the desired field(s) -// data.lastCompleted = "5/5/2023"; -// data.lastSkipped = "5/5/2023"; -// data.hoursSpent = 5; // // Put the modified data back into the object store // const putRequest = objectStore.put(data);