Fixed linter errors
This commit is contained in:
parent
47e9c39c70
commit
1d15f441d1
@ -13,3 +13,4 @@ linters:
|
|||||||
- gocyclo
|
- gocyclo
|
||||||
- maligned
|
- maligned
|
||||||
- stylecheck
|
- stylecheck
|
||||||
|
- funlen
|
@ -21,6 +21,7 @@ const (
|
|||||||
|
|
||||||
// ShopItem is a purchasable item in the shop.
|
// ShopItem is a purchasable item in the shop.
|
||||||
type ShopItem struct {
|
type ShopItem struct {
|
||||||
|
ID string `json:"id" primary:"true"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
Price uint `json:"price"`
|
Price uint `json:"price"`
|
||||||
@ -28,8 +29,11 @@ type ShopItem struct {
|
|||||||
Rarity string `json:"rarity"`
|
Rarity string `json:"rarity"`
|
||||||
Order int `json:"order"`
|
Order int `json:"order"`
|
||||||
Consumable bool `json:"consumable"`
|
Consumable bool `json:"consumable"`
|
||||||
|
}
|
||||||
|
|
||||||
hasID
|
// GetID returns the ID.
|
||||||
|
func (item *ShopItem) GetID() string {
|
||||||
|
return item.ID
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetShopItem ...
|
// GetShopItem ...
|
||||||
|
15
arn/User.go
15
arn/User.go
@ -175,11 +175,11 @@ func (user *User) SendNotification(pushNotification *PushNotification) {
|
|||||||
expired := []*PushSubscription{}
|
expired := []*PushSubscription{}
|
||||||
|
|
||||||
for _, sub := range subs.Items {
|
for _, sub := range subs.Items {
|
||||||
resp, err := sub.SendNotification(pushNotification)
|
response, err := sub.SendNotification(pushNotification)
|
||||||
|
|
||||||
if resp != nil && resp.StatusCode == http.StatusGone {
|
// It is possible to receive a non-nil response with an error, so check the status.
|
||||||
|
if response != nil && response.StatusCode == http.StatusGone {
|
||||||
expired = append(expired, sub)
|
expired = append(expired, sub)
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print errors
|
// Print errors
|
||||||
@ -188,10 +188,13 @@ func (user *User) SendNotification(pushNotification *PushNotification) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Response body must be closed if no error was returned
|
||||||
|
defer response.Body.Close()
|
||||||
|
|
||||||
// Print bad status codes
|
// Print bad status codes
|
||||||
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusCreated {
|
if response.StatusCode != http.StatusOK && response.StatusCode != http.StatusCreated {
|
||||||
body, _ := ioutil.ReadAll(resp.Body)
|
body, _ := ioutil.ReadAll(response.Body)
|
||||||
fmt.Println(resp.StatusCode, string(body))
|
fmt.Println(response.StatusCode, string(body))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package admin
|
package admin
|
||||||
|
|
||||||
import "github.com/aerogo/aero"
|
import (
|
||||||
import "github.com/animenotifier/notify.moe/components"
|
"github.com/aerogo/aero"
|
||||||
|
"github.com/animenotifier/notify.moe/components"
|
||||||
|
)
|
||||||
|
|
||||||
// WebDev ...
|
// WebDev ...
|
||||||
func WebDev(ctx aero.Context) error {
|
func WebDev(ctx aero.Context) error {
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import "github.com/animenotifier/notify.moe/arn"
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
defer arn.Node.Close()
|
|
||||||
|
|
||||||
for episodes := range arn.StreamAnimeEpisodes() {
|
|
||||||
episodes.Sort()
|
|
||||||
episodes.Save()
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import "github.com/animenotifier/notify.moe/arn"
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
defer arn.Node.Close()
|
|
||||||
|
|
||||||
for episodes := range arn.StreamAnimeEpisodes() {
|
|
||||||
anime := episodes.Anime()
|
|
||||||
anime.EpisodeIDs = nil
|
|
||||||
|
|
||||||
for _, episode := range episodes.Items {
|
|
||||||
episode.ID = arn.GenerateID("Episode")
|
|
||||||
episode.AnimeID = anime.ID
|
|
||||||
episode.Save()
|
|
||||||
|
|
||||||
anime.EpisodeIDs = append(anime.EpisodeIDs, episode.ID)
|
|
||||||
}
|
|
||||||
|
|
||||||
anime.Save()
|
|
||||||
}
|
|
||||||
}
|
|
@ -15,8 +15,6 @@ func main() {
|
|||||||
futureThreshold := 8 * 7 * 24 * time.Hour
|
futureThreshold := 8 * 7 * 24 * time.Hour
|
||||||
|
|
||||||
for anime := range arn.StreamAnime() {
|
for anime := range arn.StreamAnime() {
|
||||||
modified := false
|
|
||||||
|
|
||||||
// Try to find incorrect airing dates
|
// Try to find incorrect airing dates
|
||||||
for _, episode := range anime.Episodes() {
|
for _, episode := range anime.Episodes() {
|
||||||
if episode.AiringDate.Start == "" {
|
if episode.AiringDate.Start == "" {
|
||||||
@ -35,12 +33,7 @@ func main() {
|
|||||||
// Delete the wrong airing date
|
// Delete the wrong airing date
|
||||||
episode.AiringDate.Start = ""
|
episode.AiringDate.Start = ""
|
||||||
episode.AiringDate.End = ""
|
episode.AiringDate.End = ""
|
||||||
|
episode.Save()
|
||||||
modified = true
|
|
||||||
}
|
|
||||||
|
|
||||||
if modified {
|
|
||||||
anime.Episodes().Save()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
package utils
|
package utils
|
||||||
|
|
||||||
import "time"
|
import (
|
||||||
import "github.com/animenotifier/notify.moe/arn"
|
"time"
|
||||||
|
|
||||||
|
"github.com/animenotifier/notify.moe/arn"
|
||||||
|
)
|
||||||
|
|
||||||
// UserStats ...
|
// UserStats ...
|
||||||
type UserStats struct {
|
type UserStats struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user