Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/dbv1/full_developer_apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (q *Queries) FullDeveloperApps(ctx context.Context, arg GetDeveloperAppsPar

fullDeveloperApps := make([]FullDeveloperApp, 0, len(rawDeveloperApps))
for _, d := range rawDeveloperApps {
id, _ := trashid.EncodeHashId(int(*d.UserID))
id, _ := trashid.EncodeHashId(int(d.UserID.Int32))
fullDeveloperApps = append(fullDeveloperApps, FullDeveloperApp{
GetDeveloperAppsRow: d,
UserID: id,
Expand Down
3 changes: 2 additions & 1 deletion api/dbv1/full_playlists.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"

"bridgerton.audius.co/trashid"
"github.com/jackc/pgx/v5/pgtype"
"golang.org/x/sync/errgroup"
)

Expand Down Expand Up @@ -100,7 +101,7 @@ func (q *Queries) FullPlaylists(ctx context.Context, arg GetPlaylistsParams) ([]

type MinPlaylist struct {
ID string `json:"id"`
PlaylistName *string `json:"playlist_name"`
PlaylistName pgtype.Text `json:"playlist_name"`
PlaylistOwnerID int32 `json:"playlist_owner_id"`
PlaylistID int32 `json:"playlist_id"`
Artwork SquareImage `json:"artwork"`
Expand Down
34 changes: 19 additions & 15 deletions api/dbv1/full_tracks.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"

"bridgerton.audius.co/trashid"
"bridgerton.audius.co/utils"
"github.com/jackc/pgx/v5/pgtype"
)

type FullTracksParams GetTracksParams
Expand All @@ -16,6 +16,10 @@ type FullTrack struct {
Artwork SquareImage `json:"artwork"`
UserID string `json:"user_id"`
User FullUser `json:"user"`

// todo: fill this out
FolloweeFavorites []FullUser `json:"followee_favorites"`
FolloweeReposts []FullUser `json:"followee_reposts"`
}

func (q *Queries) FullTracks(ctx context.Context, arg GetTracksParams) ([]FullTrack, error) {
Expand Down Expand Up @@ -66,27 +70,27 @@ func (q *Queries) FullTracks(ctx context.Context, arg GetTracksParams) ([]FullTr

type MinTrack struct {
ID string `json:"id"`
Title *string `json:"title"`
Title pgtype.Text `json:"title"`
User MinUser `json:"user"`
Artwork SquareImage `json:"artwork"`
Duration *int32 `json:"duration"`
Description *string `json:"description"`
Genre *string `json:"genre"`
TrackCid *string `json:"track_cid"`
PreviewCid *string `json:"preview_cid"`
OrigFileCid *string `json:"orig_file_cid"`
OrigFilename *string `json:"orig_filename"`
Duration pgtype.Int4 `json:"duration"`
Description pgtype.Text `json:"description"`
Genre pgtype.Text `json:"genre"`
TrackCid pgtype.Text `json:"track_cid"`
PreviewCid pgtype.Text `json:"preview_cid"`
OrigFileCid pgtype.Text `json:"orig_file_cid"`
OrigFilename pgtype.Text `json:"orig_filename"`
IsOriginalAvailable bool `json:"is_original_available"`
Mood *string `json:"mood"`
Mood pgtype.Text `json:"mood"`
ReleaseDate interface{} `json:"release_date"`
RemixOf interface{} `json:"remix_of"`
RepostCount int32 `json:"repost_count"`
FavoriteCount int32 `json:"favorite_count"`
CommentCount *int32 `json:"comment_count"`
Tags *string `json:"tags"`
CommentCount pgtype.Int4 `json:"comment_count"`
Tags pgtype.Text `json:"tags"`
IsDownloadable bool `json:"is_downloadable"`
PlayCount *int64 `json:"play_count"`
PinnedCommentID *int32 `json:"pinned_comment_id"`
PlayCount pgtype.Int8 `json:"play_count"`
PinnedCommentID pgtype.Int4 `json:"pinned_comment_id"`
PlaylistsContainingTrack []interface{} `json:"playlists_containing_track"`
AlbumBacklink interface{} `json:"album_backlink"`
IsStreamable bool `json:"is_streamable"`
Expand Down Expand Up @@ -120,7 +124,7 @@ func ToMinTrack(fullTrack FullTrack) MinTrack {
PlaylistsContainingTrack: []interface{}{}, // TODO
AlbumBacklink: nil,
IsStreamable: !fullTrack.IsDelete && !fullTrack.User.IsDeactivated,
Permalink: fmt.Sprintf("/%s/%s", utils.String(fullTrack.User.Handle), utils.String(fullTrack.Slug)),
Permalink: fmt.Sprintf("/%s/%s", fullTrack.User.Handle.String, fullTrack.Slug.String),
}
}

Expand Down
64 changes: 32 additions & 32 deletions api/dbv1/full_users.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"bridgerton.audius.co/rendezvous"
"bridgerton.audius.co/trashid"
"github.com/jackc/pgx/v5/pgtype"
)

type FullUser struct {
Expand Down Expand Up @@ -37,11 +38,10 @@ func (q *Queries) FullUsers(ctx context.Context, arg GetUsersParams) ([]FullUser
var coverPhoto RectangleImage
{
cid := ""
if user.CoverPhotoSizes != nil {
cid = *user.CoverPhotoSizes
}
if cid == "" && user.CoverPhoto != nil && !strings.HasPrefix(*user.CoverPhoto, "{") {
cid = *user.CoverPhoto
if user.CoverPhotoSizes.Valid {
cid = user.CoverPhotoSizes.String
} else if user.CoverPhoto.Valid && !strings.HasPrefix(user.CoverPhoto.String, "{") {
cid = user.CoverPhoto.String
}

// rendezvous for cid
Expand All @@ -60,8 +60,8 @@ func (q *Queries) FullUsers(ctx context.Context, arg GetUsersParams) ([]FullUser
var profilePicture = squareImageStruct(user.ProfilePictureSizes, user.ProfilePicture)

var artistPickTrackID *string
if user.ArtistPickTrackID != nil {
id, _ := trashid.EncodeHashId(int(*user.ArtistPickTrackID))
if user.ArtistPickTrackID.Valid {
id, _ := trashid.EncodeHashId(int(user.ArtistPickTrackID.Int32))
artistPickTrackID = &id
}

Expand All @@ -76,11 +76,11 @@ func (q *Queries) FullUsers(ctx context.Context, arg GetUsersParams) ([]FullUser
return fullUsers, nil
}

func squareImageStruct(maybeCids ...*string) SquareImage {
func squareImageStruct(maybeCids ...pgtype.Text) SquareImage {
cid := ""
for _, m := range maybeCids {
if m != nil && !strings.HasPrefix(*m, "{") {
cid = *m
if m.Valid && !strings.HasPrefix(m.String, "{") {
cid = m.String
break
}
}
Expand All @@ -105,37 +105,37 @@ func squareImageStruct(maybeCids ...*string) SquareImage {

type MinUser struct {
ID string `json:"id"`
AlbumCount *int64 `json:"album_count"`
AlbumCount pgtype.Int8 `json:"album_count"`
ArtistPickTrackID *string `json:"artist_pick_track_id"`
Bio *string `json:"bio"`
Bio pgtype.Text `json:"bio"`
CoverPhoto RectangleImage `json:"cover_photo"`
FolloweeCount *int64 `json:"followee_count"`
FollowerCount *int64 `json:"follower_count"`
Handle *string `json:"handle"`
FolloweeCount pgtype.Int8 `json:"followee_count"`
FollowerCount pgtype.Int8 `json:"follower_count"`
Handle pgtype.Text `json:"handle"`
IsVerified bool `json:"is_verified"`
TwitterHandle *string `json:"twitter_handle"`
InstagramHandle *string `json:"instagram_handle"`
TiktokHandle *string `json:"tiktok_handle"`
VerifiedWithTwitter *bool `json:"verified_with_twitter"`
VerifiedWithInstagram *bool `json:"verified_with_instagram"`
VerifiedWithTiktok *bool `json:"verified_with_tiktok"`
Website *string `json:"website"`
Donation *string `json:"donation"`
Location *string `json:"location"`
Name *string `json:"name"`
PlaylistCount *int64 `json:"playlist_count"`
TwitterHandle pgtype.Text `json:"twitter_handle"`
InstagramHandle pgtype.Text `json:"instagram_handle"`
TiktokHandle pgtype.Text `json:"tiktok_handle"`
VerifiedWithTwitter pgtype.Bool `json:"verified_with_twitter"`
VerifiedWithInstagram pgtype.Bool `json:"verified_with_instagram"`
VerifiedWithTiktok pgtype.Bool `json:"verified_with_tiktok"`
Website pgtype.Text `json:"website"`
Donation pgtype.Text `json:"donation"`
Location pgtype.Text `json:"location"`
Name pgtype.Text `json:"name"`
PlaylistCount pgtype.Int8 `json:"playlist_count"`
ProfilePicture SquareImage `json:"profile_picture"`
RepostCount *int64 `json:"repost_count"`
TrackCount *int64 `json:"track_count"`
RepostCount pgtype.Int8 `json:"repost_count"`
TrackCount pgtype.Int8 `json:"track_count"`
IsDeactivated bool `json:"is_deactivated"`
IsAvailable bool `json:"is_available"`
ErcWallet *string `json:"erc_wallet"`
SplWallet *string `json:"spl_wallet"`
SplUsdcPayoutWallet *string `json:"spl_usdc_payout_wallet"`
ErcWallet pgtype.Text `json:"erc_wallet"`
SplWallet pgtype.Text `json:"spl_wallet"`
SplUsdcPayoutWallet pgtype.Text `json:"spl_usdc_payout_wallet"`
SupporterCount int32 `json:"supporter_count"`
SupportingCount int32 `json:"supporting_count"`
TotalAudioBalance int32 `json:"total_audio_balance"`
Wallet *string `json:"wallet"`
Wallet pgtype.Text `json:"wallet"`
}

func ToMinUser(fullUser FullUser) MinUser {
Expand Down
20 changes: 10 additions & 10 deletions api/dbv1/get_developer_apps.sql.go

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

4 changes: 3 additions & 1 deletion api/dbv1/get_playlists.sql.go

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

70 changes: 35 additions & 35 deletions api/dbv1/get_tracks.sql.go

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

Loading
Loading