More struct work

This commit is contained in:
daru
2022-04-16 18:56:29 +02:00
parent b021e418e9
commit 95baa2f40c
7 changed files with 34 additions and 33 deletions

10
ober.go
View File

@@ -64,19 +64,19 @@ func WatchGet(ctx *fasthttp.RequestCtx) {
}
userId = user.MalID
}
animes, err := ReadAnimes()
animes, err := ReadAnimeUsers()
if err != nil {
// check if no anime were inserted
if err != nutsdb.ErrBucketEmpty {
addErrorToCtx(ctx, err)
return
}
animes = make([]Anime, 0)
animes = make([]AnimeUser, 0)
}
// apply single user logic
if usrVal != nil {
filteredAnimes := make([]Anime, 0)
filteredAnimes := make([]AnimeUser, 0)
for _, a := range animes {
for _, u := range a.Users {
if u.MalID == userId {
@@ -226,7 +226,7 @@ func processUpdateReq(ctx *fasthttp.RequestCtx, update bool) {
}
body := ctx.PostBody()
var animes []Anime
var animes []AnimeUser
err := json.Unmarshal(body, &animes)
if err != nil || len(animes) == 0 {
ctx.WriteString(err.Error())
@@ -248,7 +248,7 @@ func processUpdateReq(ctx *fasthttp.RequestCtx, update bool) {
}
}
var animeData *Anime
var animeData *AnimeUser
// update or delete request
if update {
// anime exitsts => save