Skip to content

Commit f091016

Browse files
authored
Merge pull request #27 from bestreads/hotfix-limit
APWIDAWIDNAOWDBAOUWBDB
2 parents e5c93ab + a9eabf5 commit f091016

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

internal/handlers/library.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ func GetLibrary(c *fiber.Ctx) error {
2121

2222
limit := c.Query("limit")
2323
if limit == "" {
24-
limit = "0"
24+
limit = "-1"
2525
}
2626

2727
log.Info().Msg(fmt.Sprintf("GET library for user %d with limit %s", id, limit))
2828

29-
nlimit, err := strconv.ParseUint(limit, 10, 32)
29+
nlimit, err := strconv.ParseInt(limit, 10, 32)
3030
if err != nil {
3131
log.Error().Err(err).Msg("error converting limit to int")
3232
return c.Status(fiber.StatusInternalServerError).JSON(dtos.GenericRestErrorResponse{

internal/repositories/library.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func AddBook(ctx context.Context, uid uint, bid uint, state database.ReadState)
1919
return gorm.G[database.Library](middlewares.DB(ctx)).Create(ctx, &lib)
2020
}
2121

22-
func QueryLibraryDb(ctx context.Context, uid uint, limit uint64) ([]database.Library, error) {
22+
func QueryLibraryDb(ctx context.Context, uid uint, limit int64) ([]database.Library, error) {
2323
// insane das hier random der user grepreloaded wird???
2424
return gorm.G[database.Library](middlewares.DB(ctx)).
2525
Preload("Book", nil).

internal/services/library.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func AddToLibrary(ctx context.Context, uid uint, bid uint, state database.ReadSt
1717
return repositories.AddBook(ctx, uid, bid, state)
1818
}
1919

20-
func QueryLibrary(ctx context.Context, uid uint, limit uint64) ([]dtos.LibraryResponse, error) {
20+
func QueryLibrary(ctx context.Context, uid uint, limit int64) ([]dtos.LibraryResponse, error) {
2121
libs, err := repositories.QueryLibraryDb(ctx, uid, limit)
2222
if err != nil {
2323
return []dtos.LibraryResponse{}, err

0 commit comments

Comments
 (0)