23 lines
515 B
Go
Raw Normal View History

2018-03-13 00:49:54 +00:00
package soundtracks
import (
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
)
// FilterByTag renders the best soundtracks filtered by tag.
2018-03-13 00:49:54 +00:00
func FilterByTag(ctx *aero.Context) string {
tag := ctx.Get("tag")
// Fetch all eligible tracks
tracks := arn.FilterSoundTracks(func(track *arn.SoundTrack) bool {
2018-03-13 00:49:54 +00:00
return !track.IsDraft && len(track.Media) > 0 && track.HasTag(tag)
})
// Sort the tracks by number of likes
arn.SortSoundTracksPopularFirst(tracks)
2018-03-13 00:49:54 +00:00
// Render
return render(ctx, tracks)
2018-03-13 00:49:54 +00:00
}