Fixed linter errors

This commit is contained in:
Eduard Urbach 2019-09-16 08:17:20 +09:00
parent 47e9c39c70
commit 1d15f441d1
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0
8 changed files with 26 additions and 54 deletions

View File

@ -12,4 +12,5 @@ linters:
- gochecknoinits
- gocyclo
- maligned
- stylecheck
- stylecheck
- funlen

View File

@ -21,6 +21,7 @@ const (
// ShopItem is a purchasable item in the shop.
type ShopItem struct {
ID string `json:"id" primary:"true"`
Name string `json:"name"`
Description string `json:"description"`
Price uint `json:"price"`
@ -28,8 +29,11 @@ type ShopItem struct {
Rarity string `json:"rarity"`
Order int `json:"order"`
Consumable bool `json:"consumable"`
}
hasID
// GetID returns the ID.
func (item *ShopItem) GetID() string {
return item.ID
}
// GetShopItem ...

View File

@ -175,11 +175,11 @@ func (user *User) SendNotification(pushNotification *PushNotification) {
expired := []*PushSubscription{}
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)
continue
}
// Print errors
@ -188,10 +188,13 @@ func (user *User) SendNotification(pushNotification *PushNotification) {
continue
}
// Response body must be closed if no error was returned
defer response.Body.Close()
// Print bad status codes
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusCreated {
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(resp.StatusCode, string(body))
if response.StatusCode != http.StatusOK && response.StatusCode != http.StatusCreated {
body, _ := ioutil.ReadAll(response.Body)
fmt.Println(response.StatusCode, string(body))
continue
}

View File

@ -1,7 +1,9 @@
package admin
import "github.com/aerogo/aero"
import "github.com/animenotifier/notify.moe/components"
import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/components"
)
// WebDev ...
func WebDev(ctx aero.Context) error {

View File

@ -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()
}
}

View File

@ -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()
}
}

View File

@ -15,8 +15,6 @@ func main() {
futureThreshold := 8 * 7 * 24 * time.Hour
for anime := range arn.StreamAnime() {
modified := false
// Try to find incorrect airing dates
for _, episode := range anime.Episodes() {
if episode.AiringDate.Start == "" {
@ -35,12 +33,7 @@ func main() {
// Delete the wrong airing date
episode.AiringDate.Start = ""
episode.AiringDate.End = ""
modified = true
}
if modified {
anime.Episodes().Save()
episode.Save()
}
}
}

View File

@ -1,7 +1,10 @@
package utils
import "time"
import "github.com/animenotifier/notify.moe/arn"
import (
"time"
"github.com/animenotifier/notify.moe/arn"
)
// UserStats ...
type UserStats struct {