Skip to content

Improve scheduling algorithm #3126

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

Closed
wants to merge 4 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
AlertTriangleIcon,
CalendarIcon,
ClockIcon,
LockIcon,

Check warning on line 16 in apps/calendar/src/app/[locale]/(root)/scheduler/components/ScheduleDisplay.tsx

View check run for this annotation

Codecov / codecov/patch

apps/calendar/src/app/[locale]/(root)/scheduler/components/ScheduleDisplay.tsx#L16

Added line #L16 was not covered by tests
SparklesIcon,
TrendingUpIcon,
} from '@tuturuuu/ui/icons';
Expand Down Expand Up @@ -225,15 +226,29 @@
{/* Event Card */}
<div
className={`group relative rounded-lg border p-4 transition-all hover:shadow-sm ${
event.isPastDeadline
? 'border-destructive/30 bg-destructive/5'
: 'hover:bg-accent/5'
event.locked
? 'border-dynamic-blue/30 bg-dynamic-blue/10'
: event.isPastDeadline
? 'border-destructive/30 bg-destructive/5'
: 'hover:bg-accent/5'

Check warning on line 233 in apps/calendar/src/app/[locale]/(root)/scheduler/components/ScheduleDisplay.tsx

View check run for this annotation

Codecov / codecov/patch

apps/calendar/src/app/[locale]/(root)/scheduler/components/ScheduleDisplay.tsx#L229-L233

Added lines #L229 - L233 were not covered by tests
Comment on lines +229 to +233

Choose a reason for hiding this comment

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

medium

The conditional logic for className is becoming complex. Consider extracting this logic into a helper function or using a utility like clsx to improve readability.

}`}
>
<div className="flex items-start justify-between gap-4">
<div className="flex-1 space-y-2">
{/* Event Header */}
<div className="flex items-center gap-3">
{event.locked && (
<Tooltip>
<TooltipTrigger>
<LockIcon className="h-5 w-5 shrink-0 text-dynamic-blue" />
</TooltipTrigger>
<TooltipContent>
<p>
Locked event: this time is blocked
</p>
</TooltipContent>
</Tooltip>
)}

Check warning on line 251 in apps/calendar/src/app/[locale]/(root)/scheduler/components/ScheduleDisplay.tsx

View check run for this annotation

Codecov / codecov/patch

apps/calendar/src/app/[locale]/(root)/scheduler/components/ScheduleDisplay.tsx#L240-L251

Added lines #L240 - L251 were not covered by tests
{event.isPastDeadline && (
<Tooltip>
<TooltipTrigger>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
Trash2Icon,
ZapIcon,
} from '@tuturuuu/ui/icons';
import { SplitIcon } from '@tuturuuu/ui/icons';

Check warning on line 21 in apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskList.tsx

View check run for this annotation

Codecov / codecov/patch

apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskList.tsx#L21

Added line #L21 was not covered by tests
import { Input } from '@tuturuuu/ui/input';
import { Label } from '@tuturuuu/ui/label';
import { Progress } from '@tuturuuu/ui/progress';
Expand All @@ -28,6 +29,7 @@
SelectTrigger,
SelectValue,
} from '@tuturuuu/ui/select';
import { Switch } from '@tuturuuu/ui/switch';

Check warning on line 32 in apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskList.tsx

View check run for this annotation

Codecov / codecov/patch

apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskList.tsx#L32

Added line #L32 was not covered by tests
import { Tooltip, TooltipContent, TooltipTrigger } from '@tuturuuu/ui/tooltip';
import dayjs from 'dayjs';
import { useMemo } from 'react';
Expand Down Expand Up @@ -245,6 +247,29 @@
: ''
}`}
/>
{/* Split Toggle Button */}
<div className="ml-2 flex items-center gap-1">
<Tooltip>
<TooltipTrigger asChild>
<div className="flex items-center gap-1">
<SplitIcon className="h-4 w-4 text-primary" />
<Switch
id={`split-toggle-${task.id}`}
checked={task.allowSplit ?? true}

Choose a reason for hiding this comment

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

medium

The default value for task.allowSplit is true using the nullish coalescing operator (??). This is a good default, making tasks splittable unless explicitly set otherwise.

onCheckedChange={(checked) =>
onUpdateTask(task.id, {
allowSplit: checked,
})
}
className="scale-90"
/>
</div>
</TooltipTrigger>
<TooltipContent>
Allow this task to be split into sessions
</TooltipContent>
</Tooltip>
</div>

Check warning on line 272 in apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskList.tsx

View check run for this annotation

Codecov / codecov/patch

apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskList.tsx#L250-L272

Added lines #L250 - L272 were not covered by tests
{isCompleted && (
<CheckCircleIcon className="h-5 w-5 text-dynamic-green" />
)}
Expand Down
Loading
Loading