Skip to content

Commit

Permalink
fix: use after of previous week
Browse files Browse the repository at this point in the history
  • Loading branch information
GODrums committed Nov 24, 2024
1 parent 570524d commit 1d97f0b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
16 changes: 3 additions & 13 deletions webapp/src/app/home/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,14 @@ export class HomeComponent {
};
});

protected afterParam = computed(
() =>
this.queryParams().get('after') ??
(() => {
let defaultDate = dayjs().isoWeekday(this.leaderboardSchedule().day).startOf('hour').hour(this.leaderboardSchedule().hour).minute(this.leaderboardSchedule().minute);
if (defaultDate.isAfter(dayjs())) {
defaultDate = defaultDate.subtract(1, 'week');
}
return defaultDate.format();
})()
);
protected afterParam = computed(() => this.queryParams().get('after'));
protected beforeParam = computed(() => this.queryParams().get('before') ?? dayjs().format());
protected teamParam = computed(() => this.queryParams().get('team') ?? 'all');

query = injectQuery(() => ({
enabled: !!this.metaQuery.data(),
enabled: !!this.metaQuery.data() && !!this.afterParam() && !!this.beforeParam() && !!this.teamParam(),
queryKey: ['leaderboard', { after: this.afterParam(), before: this.beforeParam(), team: this.teamParam() }],
queryFn: async () => lastValueFrom(this.leaderboardService.getLeaderboard(this.afterParam(), this.beforeParam(), this.teamParam() !== 'all' ? this.teamParam() : undefined))
queryFn: async () => lastValueFrom(this.leaderboardService.getLeaderboard(this.afterParam()!, this.beforeParam(), this.teamParam() !== 'all' ? this.teamParam() : undefined))
}));

protected teams = computed(() => this.metaQuery.data()?.teams?.map((team) => team.name) ?? []);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,15 @@ export class LeaderboardFilterTimeframeComponent {
};
});

after = computed(() => this.queryParams().get('after') ?? (this.leaderboardSchedule() ? this.leaderboardSchedule().full.format() : ''));
getDefaultDate() {
let defaultDate = dayjs().isoWeekday(this.leaderboardSchedule().day).startOf('hour').hour(this.leaderboardSchedule().hour).minute(this.leaderboardSchedule().minute);
if (defaultDate.isAfter(dayjs())) {
defaultDate = defaultDate.subtract(1, 'week');
}
return defaultDate;
}

after = computed(() => this.queryParams().get('after') ?? (this.leaderboardSchedule() ? this.getDefaultDate().format() : ''));
before = computed(() => this.queryParams().get('before') ?? dayjs().format());
selectValue = signal<string>(`${this.after()}.${this.before()}`);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class WorkspaceTeamsTableComponent {
// Controls for mutations
_newLabelName = new FormControl('');
_newTeamName = new FormControl('');
_newTeamColor = new FormControl('');
_newTeamColor = new FormControl('#000000');

displayLabelAlert = signal(false);

Expand Down

0 comments on commit 1d97f0b

Please sign in to comment.