adjusted task size and sorting so that larger tasks change the hidden effective due date and small tasks sort higher in smaller but linear way.

This commit is contained in:
2026-02-25 18:46:43 -06:00
parent 81b572422b
commit 476823394b
2 changed files with 39 additions and 16 deletions
+14 -5
View File
@@ -2,7 +2,7 @@ import { createStore, reconcile } from "solid-js/store";
import { createSignal, createEffect, createRoot } from "solid-js";
import { pb } from "@/lib/pocketbase";
import { toast } from "solid-sonner";
import { TASGRID_COLLECTION, TAGS_COLLECTION, SHARE_RULES_COLLECTION, BUCKETS_COLLECTION, URGENCY_HOURS } from "@/lib/constants";
import { TASGRID_COLLECTION, TAGS_COLLECTION, SHARE_RULES_COLLECTION, BUCKETS_COLLECTION, URGENCY_HOURS, SIZE_HOURS } from "@/lib/constants";
const LIST_FIELDS = 'id,collectionId,collectionName,created,updated,title,startDate,dueDate,priority,status,completed,tags,user,size,recurrence,sharedWith,deletedAt';
@@ -370,7 +370,17 @@ export const calculateUrgencyFromDate = (dateStr: string): number => {
};
export const getCombinedScore = (task: Task): number => {
const urgencyScore = calculateUrgencyScore(task.dueDate);
// 1. Calculate an effective due date by subtracting size hours
const size = task.size ?? 5; // Default size 5
const sizeHours = SIZE_HOURS[size] ?? 12;
const dueTime = new Date(task.dueDate).getTime();
if (isNaN(dueTime)) return 0;
// effective due date = due date - size task time
const effectiveDueTime = dueTime - (sizeHours * 60 * 60 * 1000);
const effectiveDueDateStr = new Date(effectiveDueTime).toISOString();
const urgencyScore = calculateUrgencyScore(effectiveDueDateStr);
let baseScore = (task.priority * store.pWeight) + (urgencyScore * store.uWeight);
// Tag adjustments
@@ -385,9 +395,8 @@ export const getCombinedScore = (task: Task): number => {
});
}
// Size adjustment: (size - 5) * -0.4
// Small tasks (0-4) get a slight boost, large tasks (6-10) get a slight penalty
const sizeScore = ((task.size ?? 5) - 5) * -0.4;
// Size adjustment: linear scale from +1.9 (for size 0) to 0 (for size 10)
const sizeScore = (10 - size) * 0.19;
baseScore += sizeScore;
// Status adjustment: 0-9 -> 0.0-2.0 weight