Skip to content

Commit

Permalink
refactor(movie): release date
Browse files Browse the repository at this point in the history
  • Loading branch information
believer committed Oct 1, 2024
1 parent ed68598 commit a835adf
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 40 deletions.
10 changes: 6 additions & 4 deletions handlers/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ func executeQuery(queryType string, target interface{}, query string, args ...in
}
}

type QueryTask struct {
queryFunc func() error
desc string
}

// Handler for /stats.
// Gets most of the necessary data (some is is loaded onload)
func HandleGetStats(c *fiber.Ctx) error {
Expand All @@ -63,10 +68,7 @@ func HandleGetStats(c *fiber.Ctx) error {

var wg sync.WaitGroup

queries := []struct {
queryFunc func() error
desc string
}{
queries := []QueryTask{
{executeQuery("select", &movies, "stats-most-watched-movies", userId), "stats-most-watched-movies"},
{executeQuery("select", &shortestAndLongest, "shortest-and-longest-movie", userId), "shortest-and-longest-movie"},
{executeQuery("select", &totals, "total-watched-by-job-and-year", userId, "cast", "All"), "total-watched-by-job-and-year"},
Expand Down
9 changes: 3 additions & 6 deletions views/movie.templ
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,9 @@ templ Movie(movie types.Movie, back bool) {
}
}
@components.DescriptionListItem(components.DescriptionListItemProps{Detail: "Release date"}) {
<a
class="inline-flex items-center gap-1 focus:outline-none focus-visible:rounded-sm focus-visible:outline-dashed focus-visible:outline-offset-2 focus-visible:outline-neutral-400 dark:focus-visible:outline-neutral-600 border-b border-dashed border-neutral-500 dark:border-neutral-400"
href={ movie.LinkToYear() }
>
{ movie.ReleaseDate.Format("2006-01-02") }
</a>
@components.SimpleLink(components.SimpleLinkProps{Href: movie.LinkToYear()}) {
{ movie.ISOReleaseDate() }
}
}
if movie.Runtime != 0 {
@components.DescriptionListItem(components.DescriptionListItemProps{Detail: "Runtime"}) {
Expand Down
61 changes: 31 additions & 30 deletions views/movie_templ.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a835adf

Please sign in to comment.