Removed old patches

This commit is contained in:
Eduard Urbach 2017-11-01 20:11:05 +01:00
parent e70dc0daed
commit cf00461feb
28 changed files with 57 additions and 403 deletions

View File

@ -1,18 +0,0 @@
package main
import (
"github.com/animenotifier/arn"
"github.com/fatih/color"
)
func main() {
color.Yellow("Adding balance to all users")
// Iterate over the stream
for user := range arn.StreamUsers() {
user.Balance += 100000
user.Save()
}
color.Green("Finished.")
}

View File

@ -1,22 +0,0 @@
package main
import (
"fmt"
"github.com/animenotifier/arn"
"github.com/fatih/color"
)
func main() {
color.Yellow("Addind draft indices")
// Iterate over the stream
for user := range arn.MustStreamUsers() {
fmt.Println(user.Nick)
draftIndex := arn.NewDraftIndex(user.ID)
arn.PanicOnError(draftIndex.Save())
}
color.Green("Finished.")
}

View File

@ -1,28 +0,0 @@
package main
import (
"fmt"
"github.com/animenotifier/arn"
)
func main() {
count := 0
for anime := range arn.MustStreamAnime() {
episodes := anime.Episodes()
if episodes == nil {
episodes = &arn.AnimeEpisodes{
AnimeID: anime.ID,
Items: []*arn.AnimeEpisode{},
}
if episodes.Save() == nil {
count++
}
}
}
fmt.Println("Added empty anime episodes to", count, "anime.")
}

View File

@ -1,39 +0,0 @@
package main
import (
"fmt"
"github.com/animenotifier/arn"
"github.com/fatih/color"
)
func main() {
color.Yellow("Adding user follows to users who don't have one")
// Get a stream of all users
allUsers, err := arn.StreamUsers()
arn.PanicOnError(err)
// Iterate over the stream
for user := range allUsers {
exists, err := arn.DB.Exists("UserFollows", user.ID)
if err != nil || exists {
continue
}
fmt.Println(user.Nick)
follows := &arn.UserFollows{}
follows.UserID = user.ID
follows.Items = user.Following
err = arn.DB.Set("UserFollows", follows.UserID, follows)
if err != nil {
color.Red(err.Error())
}
}
color.Green("Finished.")
}

View File

@ -19,6 +19,8 @@ func init() {
}
func main() {
defer arn.Node.Close()
if nick == "" || itemID == "" {
color.Red("Missing parameters")
return
@ -38,6 +40,5 @@ func main() {
// Add to user inventory
inventory := user.Inventory()
inventory.AddItem(itemID, uint(quantity))
err = inventory.Save()
arn.PanicOnError(err)
inventory.Save()
}

View File

@ -1,29 +0,0 @@
package main
import (
"github.com/animenotifier/arn"
)
func main() {
// Get a stream of all users
allUsers, err := arn.StreamUsers()
if err != nil {
panic(err)
}
// Iterate over the stream
for user := range allUsers {
if user.LastSeen != "" {
continue
}
user.LastSeen = user.LastLogin
if user.LastSeen == "" {
user.LastSeen = user.Registered
}
user.Save()
}
}

View File

@ -8,7 +8,9 @@ import (
)
func main() {
for anime := range arn.MustStreamAnime() {
defer arn.Node.Close()
for anime := range arn.StreamAnime() {
malID := anime.GetMapping("myanimelist/anime")
if malID == "" {
@ -25,11 +27,11 @@ func main() {
}
// Save
arn.PanicOnError(arn.DB.Set("MyAnimeListToAnime", malID, &arn.MyAnimeListToAnime{
arn.DB.Set("MyAnimeListToAnime", malID, &arn.MyAnimeListToAnime{
AnimeID: anime.ID,
ServiceID: malID,
Edited: arn.DateTimeUTC(),
EditedBy: "",
}))
})
}
}

View File

@ -1,28 +0,0 @@
package main
import (
"fmt"
"github.com/animenotifier/arn"
)
var mappings = map[string]arn.Mapping{
"13055": arn.Mapping{
Service: "shoboi/anime",
ServiceID: "4528",
},
}
func main() {
for animeID, mapping := range mappings {
anime, err := arn.GetAnime(animeID)
if err != nil {
panic(err)
}
fmt.Println(anime.ID, "=", mapping.Service, mapping.ServiceID)
anime.AddMapping(mapping.Service, mapping.ServiceID, "4J6qpK1ve")
anime.Save()
}
}

View File

@ -1,16 +0,0 @@
package main
import (
"github.com/animenotifier/arn"
)
func main() {
for anime := range arn.MustStreamAnime() {
if anime.Popularity != nil {
continue
}
anime.Popularity = &arn.AnimePopularity{}
arn.PanicOnError(anime.Save())
}
}

View File

@ -1,39 +0,0 @@
package main
import (
"fmt"
"github.com/animenotifier/arn"
"github.com/fatih/color"
)
func main() {
color.Yellow("Adding push subscriptions to users who don't have one")
// Get a stream of all users
allUsers, err := arn.StreamUsers()
if err != nil {
panic(err)
}
// Iterate over the stream
for user := range allUsers {
exists, err := arn.DB.Exists("PushSubscriptions", user.ID)
if err == nil && !exists {
fmt.Println(user.Nick)
err := arn.DB.Set("PushSubscriptions", user.ID, &arn.PushSubscriptions{
UserID: user.ID,
Items: make([]*arn.PushSubscription, 0),
})
if err != nil {
color.Red(err.Error())
}
}
}
color.Green("Finished.")
}

View File

@ -3,8 +3,10 @@ package main
import "github.com/animenotifier/arn"
func main() {
for anime := range arn.MustStreamAnime() {
defer arn.Node.Close()
for anime := range arn.StreamAnime() {
anime.Rating.Reset()
anime.MustSave()
anime.Save()
}
}

View File

@ -6,6 +6,8 @@ import (
)
func main() {
defer arn.Node.Close()
color.Yellow("Deleting all sessions...")
arn.DB.Clear("Session")
color.Green("Finished.")

View File

@ -5,11 +5,12 @@ import (
)
func main() {
for anime := range arn.MustStreamAnime() {
defer arn.Node.Close()
for anime := range arn.StreamAnime() {
providerID := anime.GetMapping("anilist/anime")
_, err := arn.DB.Delete("AniListToAnime", providerID)
arn.PanicOnError(err)
arn.DB.Delete("AniListToAnime", providerID)
anime.RemoveMapping("anilist/anime", providerID)
arn.PanicOnError(anime.Save())
anime.Save()
}
}

View File

@ -23,15 +23,12 @@ func main() {
}
color.Yellow("Resetting balance of all users to 0")
// Get a stream of all users
allUsers, err := arn.StreamUsers()
arn.PanicOnError(err)
defer arn.Node.Close()
// Iterate over the stream
for user := range allUsers {
for user := range arn.StreamUsers() {
user.Balance = 0
arn.PanicOnError(user.Save())
user.Save()
}
color.Green("Finished.")

View File

@ -1,17 +0,0 @@
package main
import (
"strings"
"github.com/animenotifier/arn"
)
func main() {
for user := range arn.MustStreamUsers() {
if !strings.HasPrefix(user.Avatar.Extension, ".") {
user.Avatar.Extension = ""
}
user.Save()
}
}

View File

@ -7,20 +7,15 @@ import (
func main() {
color.Yellow("Deleting private user data")
defer arn.Node.Close()
// Get a stream of all users
allUsers, err := arn.StreamUsers()
if err != nil {
panic(err)
}
arn.DB.DeleteTable("EmailToUser")
arn.DB.DeleteTable("GoogleToUser")
arn.DB.Clear("EmailToUser")
arn.DB.Clear("GoogleToUser")
// Iterate over the stream
count := 0
for user := range allUsers {
for user := range arn.StreamUsers() {
count++
println(count, user.Nick)

View File

@ -23,10 +23,11 @@ func main() {
}
color.Yellow("Deleting all pro subscriptions")
defer arn.Node.Close()
for user := range arn.MustStreamUsers() {
for user := range arn.StreamUsers() {
user.ProExpires = ""
arn.PanicOnError(user.Save())
user.Save()
}
color.Green("Finished.")

View File

@ -9,10 +9,12 @@ import (
)
func main() {
defer arn.Node.Close()
now := time.Now()
futureThreshold := 8 * 7 * 24 * time.Hour
for anime := range arn.MustStreamAnime() {
for anime := range arn.StreamAnime() {
modified := false
// Try to find incorrect airing dates
@ -38,7 +40,7 @@ func main() {
}
if modified == true {
arn.PanicOnError(anime.Episodes().Save())
anime.Episodes().Save()
}
}
}

View File

@ -9,16 +9,10 @@ import (
func main() {
color.Yellow("Setting list item status to correct value")
// Get a stream of all anime lists
allAnimeLists, err := arn.StreamAnimeLists()
if err != nil {
panic(err)
}
defer arn.Node.Close()
// Iterate over the stream
for animeList := range allAnimeLists {
for animeList := range arn.StreamAnimeLists() {
fmt.Println(animeList.User().Nick)
for _, item := range animeList.Items {
@ -32,8 +26,7 @@ func main() {
}
}
err := animeList.Save()
arn.PanicOnError(err)
animeList.Save()
}
color.Green("Finished.")

View File

@ -7,6 +7,8 @@ import (
)
func main() {
defer arn.Node.Close()
arn.PanicOnError(anilist.Authorize())
color.Green(anilist.AccessToken)
@ -14,9 +16,8 @@ func main() {
arn.PanicOnError(err)
count := 0
stream := anilist.StreamAnime()
for aniListAnime := range stream {
for aniListAnime := range anilist.StreamAnime() {
println(aniListAnime.TitleRomaji)
anime := arn.FindAniListAnime(aniListAnime, allAnime)

View File

@ -1,19 +0,0 @@
package main
import (
"github.com/animenotifier/arn"
)
func main() {
defer arn.Node.Close()
user, _ := arn.GetUserByNick("Akyoto")
if user.Language == ":)" {
user.Language = ":("
} else {
user.Language = ":)"
}
user.Save()
}

View File

@ -7,12 +7,10 @@ import (
)
func main() {
// Get a stream of all posts
allPosts, err := arn.StreamPosts()
arn.PanicOnError(err)
defer arn.Node.Close()
// Iterate over the stream
for post := range allPosts {
for post := range arn.StreamPosts() {
// Fix text
color.Yellow(post.Text)
post.Text = autocorrect.FixPostText(post.Text)
@ -24,7 +22,6 @@ func main() {
}
// Save
err = post.Save()
arn.PanicOnError(err)
post.Save()
}
}

View File

@ -24,21 +24,14 @@ func main() {
}
color.Yellow("Resetting all inventories")
// Get a stream of all users
allUsers, err := arn.StreamUsers()
arn.PanicOnError(err)
defer arn.Node.Close()
// Iterate over the stream
for user := range allUsers {
for user := range arn.StreamUsers() {
fmt.Println(user.Nick)
inventory := arn.NewInventory(user.ID)
err = inventory.Save()
if err != nil {
color.Red(err.Error())
}
inventory.Save()
}
color.Green("Finished.")

View File

@ -5,14 +5,13 @@ import (
)
func main() {
// Get a stream of all posts
allPosts, err := arn.StreamPosts()
arn.PanicOnError(err)
defer arn.Node.Close()
// Get a stream of all posts
threadToPosts := make(map[string][]string)
// Iterate over the stream
for post := range allPosts {
for post := range arn.StreamPosts() {
_, found := threadToPosts[post.ThreadID]
if !found {
@ -28,7 +27,6 @@ func main() {
arn.PanicOnError(err)
thread.Posts = posts
err = thread.Save()
arn.PanicOnError(err)
thread.Save()
}
}

View File

@ -1,11 +0,0 @@
package main
import (
"github.com/animenotifier/arn"
)
func main() {
for track := range arn.MustStreamSoundTracks() {
arn.PanicOnError(track.Save())
}
}

View File

@ -1,22 +0,0 @@
package main
import (
"github.com/fatih/color"
)
func main() {
color.Yellow("Updating user struct")
// // Iterate over the stream
// for user := range arn.MustStreamUsers() {
// newUser := &arn.UserNew{}
// copier.Copy(newUser, user)
// newUser.Avatar.Extension = user.Avatar
// // Save in DB
// arn.PanicOnError(arn.DB.Set("User", user.ID, newUser))
// }
color.Green("Finished.")
}

View File

@ -7,22 +7,17 @@ import (
func main() {
color.Yellow("Updating user references")
defer arn.Node.Close()
arn.DB.DeleteTable("NickToUser")
arn.DB.DeleteTable("EmailToUser")
arn.DB.DeleteTable("GoogleToUser")
arn.DB.DeleteTable("FacebookToUser")
// Get a stream of all users
allUsers, err := arn.StreamUsers()
if err != nil {
panic(err)
}
arn.DB.Clear("NickToUser")
arn.DB.Clear("EmailToUser")
arn.DB.Clear("GoogleToUser")
arn.DB.Clear("FacebookToUser")
// Iterate over the stream
count := 0
for user := range allUsers {
for user := range arn.StreamUsers() {
count++
println(count, user.Nick)

View File

@ -1,38 +0,0 @@
package main
func main() {
}
// import (
// "github.com/animenotifier/arn"
// "github.com/fatih/color"
// )
// func main() {
// // Get a stream of all anime
// allAnime, err := arn.AllAnime()
// if err != nil {
// panic(err)
// }
// // Iterate over the stream
// for _, anime := range allAnime {
// for _, trailer := range anime.Trailers {
// // trailer.ServiceID = trailer.DeprecatedVideoID
// println(trailer.DeprecatedVideoID)
// trailer.ServiceID = trailer.DeprecatedVideoID
// }
// if anime.Trailers == nil {
// anime.Trailers = []*arn.ExternalMedia{}
// }
// err := anime.Save()
// if err != nil {
// color.Red("Error saving anime: %v", err)
// }
// }
// }