diff options
Diffstat (limited to 'internal/gallery/query_photos.go')
| -rw-r--r-- | internal/gallery/query_photos.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/internal/gallery/query_photos.go b/internal/gallery/query_photos.go new file mode 100644 index 0000000..12fa877 --- /dev/null +++ b/internal/gallery/query_photos.go @@ -0,0 +1,18 @@ +package gallery + +func QueryPhotos( + photos []Photo, + query Query, +) []Photo { + if query.Offset >= len(photos) { + return []Photo{} + } + + photos = photos[query.Offset:] + + if query.Limit == 0 || query.Limit >= len(photos) { + return photos + } + + return photos[:query.Limit] +} |