Skip to content

Commit

Permalink
Fix loader not returning data correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
KillerX committed Oct 14, 2024
1 parent 36b7ee3 commit 541e5cd
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion backend/cmd/api/loaders.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ func initBatchLoaders(queries *sqlc.Queries, membersClient *members.Client) *com
return i.ID
})),
ChaptersLoader: loaders.NewListLoader(ctx, queries.GetChaptersForEpisodeID, func(i common.TimedMetadata) int {
return int(i.ParentEpisodeID.Int64)
return i.ParentEpisodeID
}),
PhraseLoader: loaders.New(ctx, queries.GetPhrases, loaders.WithName("phrases-loader"), loaders.WithKeyFunc(func(i common.Phrase) string {
return i.Key
Expand Down
2 changes: 1 addition & 1 deletion backend/common/items.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ type TimedMetadata struct {
SongID uuid.NullUUID
MediaItemID uuid.NullUUID
Images Images
ParentEpisodeID null.Int
ParentEpisodeID int
}

// Short item type
Expand Down
2 changes: 1 addition & 1 deletion backend/sqlc/timedmetadata-queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (q *Queries) GetChaptersForEpisodeID(ctx context.Context, ids []int) ([]com
Description: description,
MediaItemID: i.MediaitemID,
Images: q.getImages(i.Images),
ParentEpisodeID: i.EpisodeID,
ParentEpisodeID: int(i.EpisodeID),
}
}), nil
}
7 changes: 4 additions & 3 deletions backend/sqlc/timedmetadata.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions queries/timedmetadata.sql
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ DELETE FROM timedmetadata WHERE asset_id = @asset_id;

-- name: getChaptesFromEpisode :many
SELECT
e.id as episode_id,
tm.id::uuid as id,
tm.type::text as type,
tm.episode_id,
tm.content_type,
tm.song_id,
(SELECT array_agg(c.person_id) FROM "contributions" c WHERE c.timedmetadata_id = tm.id)::uuid[] AS person_ids,
Expand Down Expand Up @@ -166,5 +166,5 @@ FROM episodes e
) images ON (images.timedmetadata_id = tm.id)
WHERE e.id= ANY(@episode_ids::int[])
AND tm.status = 'published'
AND tm.type = 'chapter';
;
AND tm.type = 'chapter'
ORDER BY tm.seconds ASC;

0 comments on commit 541e5cd

Please sign in to comment.