diff --git a/main.go b/main.go index 45cf262a..37390d3f 100644 --- a/main.go +++ b/main.go @@ -63,7 +63,7 @@ func configure(app *aero.Application) *aero.Application { // Close the database node on shutdown app.OnShutdown(arn.Node.Close) - // Prefetch data from all collections + // Prefetch all collections arn.DB.Prefetch() // Specify test routes diff --git a/pages/explore/explore.go b/pages/explore/explore.go index be55016b..1573e2d4 100644 --- a/pages/explore/explore.go +++ b/pages/explore/explore.go @@ -53,3 +53,28 @@ func Get(ctx *aero.Context) string { return ctx.HTML(components.Explore(animeList)) } + +// Filter ... +func Filter(ctx *aero.Context) string { + year := ctx.Get("year") + status := ctx.Get("status") + + var results []*arn.Anime + + for anime := range arn.StreamAnime() { + if len(anime.StartDate) < 4 { + continue + } + + if anime.StartDate[:4] != year { + continue + } + + if anime.Status != status { + continue + } + + } + + return ctx.HTML(components.Explore(results)) +} diff --git a/pages/index.go b/pages/index.go index 0d760e3d..d4b1db66 100644 --- a/pages/index.go +++ b/pages/index.go @@ -50,6 +50,7 @@ func Configure(app *aero.Application) { // Main menu app.Ajax("/", home.Get) app.Ajax("/explore", explore.Get) + app.Ajax("/explore/:year/:status", explore.Filter) app.Ajax("/login", login.Get) app.Ajax("/api", apiview.Get) // app.Ajax("/dashboard", dashboard.Get)