@@ -13,9 +13,9 @@ import (
1313type FullUser struct {
1414 GetUsersRow
1515
16- ArtistPickTrackID * string `json:"artist_pick_track_id"`
17- ProfilePicture SquareImage `json:"profile_picture"`
18- CoverPhoto RectangleImage `json:"cover_photo"`
16+ ArtistPickTrackID * string `json:"artist_pick_track_id"`
17+ ProfilePicture * SquareImage `json:"profile_picture"`
18+ CoverPhoto * RectangleImage `json:"cover_photo"`
1919}
2020
2121func (q * Queries ) FullUsersKeyed (ctx context.Context , arg GetUsersParams ) (map [int32 ]FullUser , error ) {
@@ -35,7 +35,7 @@ func (q *Queries) FullUsersKeyed(ctx context.Context, arg GetUsersParams) (map[i
3535 user .ID , _ = trashid .EncodeHashId (int (user .UserID ))
3636
3737 // profile picture + cover photo
38- var coverPhoto RectangleImage
38+ var coverPhoto * RectangleImage
3939 {
4040 cid := ""
4141 if user .CoverPhotoSizes .Valid {
@@ -44,15 +44,17 @@ func (q *Queries) FullUsersKeyed(ctx context.Context, arg GetUsersParams) (map[i
4444 cid = user .CoverPhoto .String
4545 }
4646
47- // rendezvous for cid
48- rankedHosts := rendezvous .GlobalHasher .Rank (cid )
49- first := rankedHosts [0 ]
50- rest := rankedHosts [1 :3 ]
51-
52- coverPhoto = RectangleImage {
53- X640 : fmt .Sprintf ("%s/content/%s/640x.jpg" , first , cid ),
54- X2000 : fmt .Sprintf ("%s/content/%s/2000x.jpg" , first , cid ),
55- Mirrors : rest ,
47+ if cid != "" {
48+ // rendezvous for cid
49+ rankedHosts := rendezvous .GlobalHasher .Rank (cid )
50+ first := rankedHosts [0 ]
51+ rest := rankedHosts [1 :3 ]
52+
53+ coverPhoto = & RectangleImage {
54+ X640 : fmt .Sprintf ("%s/content/%s/640x.jpg" , first , cid ),
55+ X2000 : fmt .Sprintf ("%s/content/%s/2000x.jpg" , first , cid ),
56+ Mirrors : rest ,
57+ }
5658 }
5759 }
5860
@@ -94,7 +96,7 @@ func (q *Queries) FullUsers(ctx context.Context, arg GetUsersParams) ([]FullUser
9496 return fullUsers , nil
9597}
9698
97- func squareImageStruct (maybeCids ... pgtype.Text ) SquareImage {
99+ func squareImageStruct (maybeCids ... pgtype.Text ) * SquareImage {
98100 cid := ""
99101 for _ , m := range maybeCids {
100102 if m .Valid && ! strings .HasPrefix (m .String , "{" ) {
@@ -104,16 +106,15 @@ func squareImageStruct(maybeCids ...pgtype.Text) SquareImage {
104106 }
105107
106108 if cid == "" {
107- // todo: what to do here?
108- return SquareImage {}
109+ return nil
109110 }
110111
111112 // rendezvous for cid
112113 rankedHosts := rendezvous .GlobalHasher .Rank (cid )
113114 first := rankedHosts [0 ]
114115 rest := rankedHosts [1 :3 ]
115116
116- return SquareImage {
117+ return & SquareImage {
117118 X150x150 : fmt .Sprintf ("%s/content/%s/150x150.jpg" , first , cid ),
118119 X480x480 : fmt .Sprintf ("%s/content/%s/480x480.jpg" , first , cid ),
119120 X1000x1000 : fmt .Sprintf ("%s/content/%s/1000x1000.jpg" , first , cid ),
@@ -122,38 +123,38 @@ func squareImageStruct(maybeCids ...pgtype.Text) SquareImage {
122123}
123124
124125type MinUser struct {
125- ID string `json:"id"`
126- AlbumCount pgtype.Int8 `json:"album_count"`
127- ArtistPickTrackID * string `json:"artist_pick_track_id"`
128- Bio pgtype.Text `json:"bio"`
129- CoverPhoto RectangleImage `json:"cover_photo"`
130- FolloweeCount pgtype.Int8 `json:"followee_count"`
131- FollowerCount pgtype.Int8 `json:"follower_count"`
132- Handle pgtype.Text `json:"handle"`
133- IsVerified bool `json:"is_verified"`
134- TwitterHandle pgtype.Text `json:"twitter_handle"`
135- InstagramHandle pgtype.Text `json:"instagram_handle"`
136- TiktokHandle pgtype.Text `json:"tiktok_handle"`
137- VerifiedWithTwitter pgtype.Bool `json:"verified_with_twitter"`
138- VerifiedWithInstagram pgtype.Bool `json:"verified_with_instagram"`
139- VerifiedWithTiktok pgtype.Bool `json:"verified_with_tiktok"`
140- Website pgtype.Text `json:"website"`
141- Donation pgtype.Text `json:"donation"`
142- Location pgtype.Text `json:"location"`
143- Name pgtype.Text `json:"name"`
144- PlaylistCount pgtype.Int8 `json:"playlist_count"`
145- ProfilePicture SquareImage `json:"profile_picture"`
146- RepostCount pgtype.Int8 `json:"repost_count"`
147- TrackCount pgtype.Int8 `json:"track_count"`
148- IsDeactivated bool `json:"is_deactivated"`
149- IsAvailable bool `json:"is_available"`
150- ErcWallet pgtype.Text `json:"erc_wallet"`
151- SplWallet pgtype.Text `json:"spl_wallet"`
152- SplUsdcPayoutWallet pgtype.Text `json:"spl_usdc_payout_wallet"`
153- SupporterCount int32 `json:"supporter_count"`
154- SupportingCount int32 `json:"supporting_count"`
155- TotalAudioBalance int32 `json:"total_audio_balance"`
156- Wallet pgtype.Text `json:"wallet"`
126+ ID string `json:"id"`
127+ AlbumCount pgtype.Int8 `json:"album_count"`
128+ ArtistPickTrackID * string `json:"artist_pick_track_id"`
129+ Bio pgtype.Text `json:"bio"`
130+ CoverPhoto * RectangleImage `json:"cover_photo"`
131+ FolloweeCount pgtype.Int8 `json:"followee_count"`
132+ FollowerCount pgtype.Int8 `json:"follower_count"`
133+ Handle pgtype.Text `json:"handle"`
134+ IsVerified bool `json:"is_verified"`
135+ TwitterHandle pgtype.Text `json:"twitter_handle"`
136+ InstagramHandle pgtype.Text `json:"instagram_handle"`
137+ TiktokHandle pgtype.Text `json:"tiktok_handle"`
138+ VerifiedWithTwitter pgtype.Bool `json:"verified_with_twitter"`
139+ VerifiedWithInstagram pgtype.Bool `json:"verified_with_instagram"`
140+ VerifiedWithTiktok pgtype.Bool `json:"verified_with_tiktok"`
141+ Website pgtype.Text `json:"website"`
142+ Donation pgtype.Text `json:"donation"`
143+ Location pgtype.Text `json:"location"`
144+ Name pgtype.Text `json:"name"`
145+ PlaylistCount pgtype.Int8 `json:"playlist_count"`
146+ ProfilePicture * SquareImage `json:"profile_picture"`
147+ RepostCount pgtype.Int8 `json:"repost_count"`
148+ TrackCount pgtype.Int8 `json:"track_count"`
149+ IsDeactivated bool `json:"is_deactivated"`
150+ IsAvailable bool `json:"is_available"`
151+ ErcWallet pgtype.Text `json:"erc_wallet"`
152+ SplWallet pgtype.Text `json:"spl_wallet"`
153+ SplUsdcPayoutWallet pgtype.Text `json:"spl_usdc_payout_wallet"`
154+ SupporterCount int32 `json:"supporter_count"`
155+ SupportingCount int32 `json:"supporting_count"`
156+ TotalAudioBalance int32 `json:"total_audio_balance"`
157+ Wallet pgtype.Text `json:"wallet"`
157158}
158159
159160func ToMinUser (fullUser FullUser ) MinUser {
0 commit comments