--wip-- [skip ci]

This commit is contained in:
schreifuchs committed 2026-09-14 20:24:56 +02:00
1 parent 72bc974aa6
commit bca93f6c6c
12 files changed
+256 -54

No files matched your search

+30
View File
@@ -12,6 +12,7 @@ import (
"time"
"git.schreifuchs.ch/schreifuchs/schreifuchs.ch/internal/components/images"
"git.schreifuchs.ch/schreifuchs/schreifuchs.ch/internal/handlers/rest"
"github.com/valkey-io/valkey-go"
)
@@ -124,3 +125,32 @@ func (s *Service) GetImages(ctx context.Context) (images []Image, err error) {
err = s.cache.Do(ctx, s.cache.B().Get().Key(imagesKey).Build()).DecodeJSON(&images)
return
}
func (s *Service) GetPrevAndNext(ctx context.Context, uid string) (previous *Image, next *Image, err error) {
imgs, err := s.GetImages(ctx)
if err != nil {
return
}
for i := range imgs {
if imgs[i].UID != uid {
continue
}
if i-1 >= 0 {
previous = &imgs[i-1]
}
if i+1 >= len(imgs) {
next = &imgs[i+1]
}
return
}
err = &rest.Error{
Type: rest.ErrorTypeNotFound,
Message: "could not find image with uid",
}
return
}