Started working on explore filters

This commit is contained in:
Eduard Urbach 2017-11-07 17:00:09 +01:00
parent f6c4545f5c
commit f5935ab12b
3 changed files with 27 additions and 1 deletions

View File

@ -63,7 +63,7 @@ func configure(app *aero.Application) *aero.Application {
// Close the database node on shutdown // Close the database node on shutdown
app.OnShutdown(arn.Node.Close) app.OnShutdown(arn.Node.Close)
// Prefetch data from all collections // Prefetch all collections
arn.DB.Prefetch() arn.DB.Prefetch()
// Specify test routes // Specify test routes

View File

@ -53,3 +53,28 @@ func Get(ctx *aero.Context) string {
return ctx.HTML(components.Explore(animeList)) 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))
}

View File

@ -50,6 +50,7 @@ func Configure(app *aero.Application) {
// Main menu // Main menu
app.Ajax("/", home.Get) app.Ajax("/", home.Get)
app.Ajax("/explore", explore.Get) app.Ajax("/explore", explore.Get)
app.Ajax("/explore/:year/:status", explore.Filter)
app.Ajax("/login", login.Get) app.Ajax("/login", login.Get)
app.Ajax("/api", apiview.Get) app.Ajax("/api", apiview.Get)
// app.Ajax("/dashboard", dashboard.Get) // app.Ajax("/dashboard", dashboard.Get)