diff --git a/api/schedule_history_list_by_day.go b/api/schedule_history_list_by_day.go index 8339fb9..b4c3a1c 100644 --- a/api/schedule_history_list_by_day.go +++ b/api/schedule_history_list_by_day.go @@ -17,16 +17,24 @@ type ScheduleHistoryListByDateParams struct { func (params *ScheduleHistoryListByDateParams) FillFromQuery(query Queryable) { var err error params.Date, err = time.Parse("2006-01-02", query.Get("date")) + now := time.Now() if err != nil { - params.Date = time.Now() + params.Date = now + } + queryDate := time.Date(params.Date.Year(), params.Date.Month(), params.Date.Day(), 0, 0, 0, 0, now.Location()) + today := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, now.Location()) + if queryDate.After(today) { + params.Date = today } } func (params *ScheduleHistoryListByDateParams) CountQuery() (expr []bob.Mod[*dialect.SelectQuery]) { unixTopTime := time.Date(params.Date.Year(), params.Date.Month(), params.Date.Day(), 23, 59, 59, 0, params.Date.Location()).Unix() unixLowTime := time.Date(params.Date.Year(), params.Date.Month(), params.Date.Day(), 0, 0, 0, 0, params.Date.Location()).Unix() - expr = append(expr, models.SelectWhere.ScheduleHistories.CreatedAt.GTE(unixLowTime)) - expr = append(expr, models.SelectWhere.ScheduleHistories.CreatedAt.LTE(unixTopTime)) + expr = append(expr, + models.SelectWhere.ScheduleHistories.CreatedAt.GTE(unixLowTime), + models.SelectWhere.ScheduleHistories.CreatedAt.LTE(unixTopTime), + ) return } diff --git a/views/schedulehistories/view.templ b/views/schedulehistories/view.templ index c2287c7..6584e30 100644 --- a/views/schedulehistories/view.templ +++ b/views/schedulehistories/view.templ @@ -42,39 +42,7 @@ templ Content(c *views.Context, data Data) {

Schedule History ({ time.Local.String() })

-
- if data.isCurrentDay() { - - @icons.Refresh("w-6 h-6") - - } else { - - @icons.ChevronBoldLeft("w-6 h-6") - - } - { data.Params.Date.Format("Monday, 02 January 2006") } - { data.Params.Date.Format("Mon, 02 Jan") } - -
+ @dateBar(data, true) if len(data.ScheduleHistories) == 0 {

There are no history schedules found for current date.

} @@ -143,9 +111,74 @@ templ Content(c *views.Context, data Data) { } } + if len(data.ScheduleHistories) > 20 { + @dateBar(data, false) + } + @actionButton(data)
} +templ actionButton(data Data) { +
+ @components.ActionButton( + actionButtonNext(data), + actionButtonPrev(data), + ) +
+} + +templ dateBar(data Data, showDate bool) { +
+ if data.isCurrentDay() { + + @icons.Refresh("w-6 h-6") + + } else { + + @icons.ChevronBoldLeft("w-6 h-6") + + } + if showDate { + { data.Params.Date.Format("Monday, 02 January 2006") } + { data.Params.Date.Format("Mon, 02 Jan") } + } +
+ + @icons.ChevronBoldRight("w-6 h-6") + +
+
+} + +templ actionButtonNext(data Data) { + Next +} + +templ actionButtonPrev(data Data) { + Previous +} + templ subredditLink(subreddit string) { { subreddit } }