Started working on explore filters
This commit is contained in:
parent
f6c4545f5c
commit
f5935ab12b
2
main.go
2
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
|
||||
|
@ -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))
|
||||
}
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user