@@ -2,6 +2,7 @@ package dbv1
22
33import (
44 "context"
5+ "encoding/json"
56 "fmt"
67
78 "bridgerton.audius.co/trashid"
@@ -24,6 +25,7 @@ type FullTrack struct {
2425
2526 FolloweeReposts []* FolloweeRepost `json:"followee_reposts"`
2627 FolloweeFavorites []* FolloweeFavorite `json:"followee_favorites"`
28+ RemixOf FullRemixOf `json:"remix_of"`
2729}
2830
2931func (q * Queries ) FullTracksKeyed (ctx context.Context , arg GetTracksParams ) (map [int32 ]FullTrack , error ) {
@@ -35,6 +37,12 @@ func (q *Queries) FullTracksKeyed(ctx context.Context, arg GetTracksParams) (map
3537 userIds := []int32 {}
3638 for _ , track := range rawTracks {
3739 userIds = append (userIds , track .UserID )
40+
41+ var remixOf RemixOf
42+ json .Unmarshal (track .RemixOf , & remixOf )
43+ for _ , r := range remixOf .Tracks {
44+ userIds = append (userIds , r .ParentUserId )
45+ }
3846 }
3947
4048 userMap , err := q .FullUsersKeyed (ctx , GetUsersParams {
@@ -76,6 +84,23 @@ func (q *Queries) FullTracksKeyed(ctx context.Context, arg GetTracksParams) (map
7684 track .FieldVisibility = []byte (`{}` )
7785 }
7886
87+ // remix_of
88+ var remixOf RemixOf
89+ var fullRemixOf FullRemixOf
90+ json .Unmarshal (track .RemixOf , & remixOf )
91+ fullRemixOf = FullRemixOf {
92+ Tracks : make ([]FullRemixOfTrack , len (remixOf .Tracks )),
93+ }
94+ for idx , r := range remixOf .Tracks {
95+ trackId , _ := trashid .EncodeHashId (int (r .ParentTrackId ))
96+ fullRemixOf .Tracks [idx ] = FullRemixOfTrack {
97+ HasRemixAuthorReposted : r .HasRemixAuthorReposted ,
98+ HasRemixAuthorSaved : r .HasRemixAuthorSaved ,
99+ ParentTrackId : trackId ,
100+ User : userMap [r .ParentUserId ],
101+ }
102+ }
103+
79104 fullTrack := FullTrack {
80105 GetTracksRow : track ,
81106 IsStreamable : ! track .IsDelete && ! user .IsDeactivated ,
@@ -88,6 +113,7 @@ func (q *Queries) FullTracksKeyed(ctx context.Context, arg GetTracksParams) (map
88113 UserID : user .ID ,
89114 FolloweeFavorites : fullFolloweeFavorites (track .FolloweeFavorites ),
90115 FolloweeReposts : fullFolloweeReposts (track .FolloweeReposts ),
116+ RemixOf : fullRemixOf ,
91117 }
92118 trackMap [track .TrackID ] = fullTrack
93119 }
0 commit comments