98 lines
2.5 KiB
Go
Raw Normal View History

2016-11-19 14:54:31 +00:00
package dashboard
2018-04-08 20:44:21 +00:00
// import (
// "net/http"
// "sort"
2017-06-28 19:17:49 +00:00
2018-04-08 20:44:21 +00:00
// "github.com/aerogo/aero"
// "github.com/aerogo/flow"
// "github.com/animenotifier/arn"
// "github.com/animenotifier/notify.moe/components"
// "github.com/animenotifier/notify.moe/utils"
// )
2016-11-19 14:54:31 +00:00
2018-04-08 20:44:21 +00:00
// const maxForumActivity = 5
// const maxFollowing = 5
// const maxSoundTracks = 5
// const maxScheduleItems = 5
2018-04-08 20:44:21 +00:00
// // Get the dashboard.
// func Get(ctx *aero.Context) string {
// var forumActivity []arn.Postable
// var followingList []*arn.User
// var soundTracks []*arn.SoundTrack
// var upcomingEpisodes []*arn.UpcomingEpisode
2017-06-26 17:03:48 +00:00
2018-04-08 20:44:21 +00:00
// user := utils.GetUser(ctx)
2017-06-07 19:12:59 +00:00
2018-04-08 20:44:21 +00:00
// if user == nil {
2018-07-07 03:42:00 +00:00
// return ctx.Error(http.StatusUnauthorized, "Not logged in")
2018-04-08 20:44:21 +00:00
// }
2017-10-02 04:29:58 +00:00
2018-04-08 20:44:21 +00:00
// flow.Parallel(func() {
// posts := arn.AllPosts()
// threads := arn.AllThreads()
2017-11-01 08:45:14 +00:00
2018-04-08 20:44:21 +00:00
// arn.SortPostsLatestFirst(posts)
// arn.SortThreadsLatestFirst(threads)
2017-11-01 08:45:14 +00:00
2018-04-08 20:44:21 +00:00
// posts = arn.FilterPostsWithUniqueThreads(posts, maxForumActivity)
2017-11-01 08:45:14 +00:00
2018-04-08 20:44:21 +00:00
// postPostables := arn.ToPostables(posts)
// threadPostables := arn.ToPostables(threads)
2017-11-01 08:45:14 +00:00
2018-04-08 20:44:21 +00:00
// allPostables := append(postPostables, threadPostables...)
2017-11-01 08:45:14 +00:00
2018-04-08 20:44:21 +00:00
// arn.SortPostablesLatestFirst(allPostables)
// forumActivity = arn.FilterPostablesWithUniqueThreads(allPostables, maxForumActivity)
// }, func() {
// animeList, err := arn.GetAnimeList(user.ID)
2017-06-28 19:17:49 +00:00
2018-04-08 20:44:21 +00:00
// if err != nil {
// return
// }
2017-06-28 19:17:49 +00:00
2018-04-08 20:44:21 +00:00
// animeList = animeList.Watching()
// animeList.Lock()
2017-06-28 19:17:49 +00:00
2018-04-08 20:44:21 +00:00
// for _, item := range animeList.Items {
// futureEpisodes := item.Anime().UpcomingEpisodes()
2017-06-29 06:32:46 +00:00
2018-04-08 20:44:21 +00:00
// if len(futureEpisodes) == 0 {
// continue
// }
2017-06-29 06:32:46 +00:00
2018-04-08 20:44:21 +00:00
// upcomingEpisodes = append(upcomingEpisodes, futureEpisodes...)
// }
2017-06-28 19:32:13 +00:00
2018-04-08 20:44:21 +00:00
// animeList.Unlock()
2017-11-24 14:14:29 +00:00
2018-04-08 20:44:21 +00:00
// sort.Slice(upcomingEpisodes, func(i, j int) bool {
// return upcomingEpisodes[i].Episode.AiringDate.Start < upcomingEpisodes[j].Episode.AiringDate.Start
// })
2017-07-10 18:51:06 +00:00
2018-04-08 20:44:21 +00:00
// if len(upcomingEpisodes) >= maxScheduleItems {
// upcomingEpisodes = upcomingEpisodes[:maxScheduleItems]
// }
// }, func() {
// soundTracks = arn.FilterSoundTracks(func(track *arn.SoundTrack) bool {
// return !track.IsDraft && len(track.Media) > 0
// })
2017-06-27 14:51:27 +00:00
2018-04-08 20:44:21 +00:00
// arn.SortSoundTracksLatestFirst(soundTracks)
2017-06-27 14:51:27 +00:00
2018-04-08 20:44:21 +00:00
// if len(soundTracks) > maxSoundTracks {
// soundTracks = soundTracks[:maxSoundTracks]
// }
// }, func() {
// followingList = user.Follows().Users()
// arn.SortUsersLastSeen(followingList)
2017-06-26 16:53:06 +00:00
2018-04-08 20:44:21 +00:00
// if len(followingList) > maxFollowing {
// followingList = followingList[:maxFollowing]
// }
// })
2018-04-08 20:44:21 +00:00
// return ctx.HTML(components.Dashboard(upcomingEpisodes, forumActivity, soundTracks, followingList, user))
// }