Removed old jobs

This commit is contained in:
Eduard Urbach 2017-11-01 11:16:31 +01:00
parent b0d03fe8ef
commit 46dd9f53a8
6 changed files with 8 additions and 166 deletions

View File

@ -1,49 +0,0 @@
package main
import (
"github.com/animenotifier/arn"
"github.com/fatih/color"
)
const maxEntries = 5
func main() {
color.Yellow("Caching list of forum activities")
posts, err := arn.AllPosts()
arn.PanicOnError(err)
threads, err := arn.AllThreads()
arn.PanicOnError(err)
arn.SortPostsLatestFirst(posts)
arn.SortThreadsLatestFirst(threads)
posts = arn.FilterPostsWithUniqueThreads(posts, maxEntries)
postPostables := arn.ToPostables(posts)
threadPostables := arn.ToPostables(threads)
allPostables := append(postPostables, threadPostables...)
arn.SortPostablesLatestFirst(allPostables)
cachedPostables := arn.FilterPostablesWithUniqueThreads(allPostables, maxEntries)
cache := &arn.ListOfMappedIDs{}
for _, postable := range cachedPostables {
cache.Append(postable.Type(), postable.ID())
}
// // Debug log
// arn.PrettyPrint(cache)
// // Try to resolve
// for _, r := range arn.ToPostables(cache.Resolve()) {
// color.Green(r.Title())
// }
arn.PanicOnError(arn.DB.Set("Cache", "forum activity", cache))
color.Green("Finished.")
}

View File

@ -1,62 +0,0 @@
package main
import (
"sort"
"github.com/animenotifier/arn"
"github.com/fatih/color"
)
const maxPopularAnime = 10
// Note this is using the airing-anime as a template with modfications
// made to it.
func main() {
color.Yellow("Caching popular anime")
// Fetch all anime
animeList, err := arn.AllAnime()
arn.PanicOnError(err)
// Overall
sort.Slice(animeList, func(i, j int) bool {
return animeList[i].Rating.Overall > animeList[j].Rating.Overall
})
saveAs(animeList[:maxPopularAnime], "best anime overall")
// Story
sort.Slice(animeList, func(i, j int) bool {
return animeList[i].Rating.Story > animeList[j].Rating.Story
})
saveAs(animeList[:maxPopularAnime], "best anime story")
// Visuals
sort.Slice(animeList, func(i, j int) bool {
return animeList[i].Rating.Visuals > animeList[j].Rating.Visuals
})
saveAs(animeList[:maxPopularAnime], "best anime visuals")
// Soundtrack
sort.Slice(animeList, func(i, j int) bool {
return animeList[i].Rating.Soundtrack > animeList[j].Rating.Soundtrack
})
saveAs(animeList[:maxPopularAnime], "best anime soundtrack")
// Done.
color.Green("Finished.")
}
// Convert to ListOfIDs and save in cache.
func saveAs(list []*arn.Anime, cacheKey string) {
cache := &arn.ListOfIDs{}
for _, anime := range list {
cache.IDList = append(cache.IDList, anime.ID)
}
arn.PanicOnError(arn.DB.Set("Cache", cacheKey, cache))
}

View File

@ -1,37 +0,0 @@
package main
import (
"github.com/animenotifier/arn"
"github.com/fatih/color"
)
func main() {
color.Yellow("Refreshing track titles")
// Get a stream of all soundtracks
soundtracks, err := arn.StreamSoundTracks()
if err != nil {
panic(err)
}
// Iterate over the stream
for track := range soundtracks {
sync(track)
}
color.Green("Finished.")
}
func sync(track *arn.SoundTrack) {
// for _, media := range track.Media {
// media.RefreshMetaData()
// println(media.Service, media.Title)
// }
// err := track.Save()
// if err != nil {
// panic(err)
// }
}

View File

@ -10,6 +10,7 @@ import (
func main() { func main() {
color.Yellow("Syncing characters with Kitsu DB") color.Yellow("Syncing characters with Kitsu DB")
defer arn.Node.Close()
kitsuCharacters := kitsu.StreamCharacters() kitsuCharacters := kitsu.StreamCharacters()
@ -23,7 +24,7 @@ func main() {
fmt.Printf("%s %s\n", character.ID, character.Name) fmt.Printf("%s %s\n", character.ID, character.Name)
arn.PanicOnError(character.Save()) character.Save()
} }
color.Green("Finished.") color.Green("Finished.")

View File

@ -12,6 +12,7 @@ import (
func main() { func main() {
color.Yellow("Syncing media relations with Kitsu DB") color.Yellow("Syncing media relations with Kitsu DB")
defer arn.Node.Close()
kitsuMediaRelations := kitsu.StreamMediaRelations() kitsuMediaRelations := kitsu.StreamMediaRelations()
relations := map[string]*arn.AnimeRelations{} relations := map[string]*arn.AnimeRelations{}
@ -27,15 +28,11 @@ func main() {
destinationAnimeID := mediaRelation.Relationships.Destination.Data.ID destinationAnimeID := mediaRelation.Relationships.Destination.Data.ID
// Confirm that the anime IDs are valid // Confirm that the anime IDs are valid
exists, _ := arn.DB.Exists("Anime", animeID) if !arn.DB.Exists("Anime", animeID) {
if !exists {
continue continue
} }
exists, _ = arn.DB.Exists("Anime", destinationAnimeID) if !arn.DB.Exists("Anime", destinationAnimeID) {
if !exists {
continue continue
} }
@ -71,11 +68,7 @@ func main() {
// Save relations map // Save relations map
for _, animeRelations := range relations { for _, animeRelations := range relations {
err := animeRelations.Save() animeRelations.Save()
if err != nil {
color.Red(err.Error())
}
} }
color.Green("Finished.") color.Green("Finished.")

View File

@ -8,14 +8,10 @@ import (
func main() { func main() {
color.Yellow("Adding balance to all users") color.Yellow("Adding balance to all users")
// Get a stream of all users
allUsers, err := arn.StreamUsers()
arn.PanicOnError(err)
// Iterate over the stream // Iterate over the stream
for user := range allUsers { for user := range arn.StreamUsers() {
user.Balance += 100000 user.Balance += 100000
arn.PanicOnError(user.Save()) user.Save()
} }
color.Green("Finished.") color.Green("Finished.")