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
18 changes: 18 additions & 0 deletions api/dbv1/full_developer_apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,21 @@ func (q *Queries) FullDeveloperApps(ctx context.Context, arg GetDeveloperAppsPar

return fullDeveloperApps, nil
}

type MinDeveloperApp struct {
FullDeveloperApp
}

func ToMinDeveloperApp(fullDeveloperApp FullDeveloperApp) MinDeveloperApp {
return MinDeveloperApp{
FullDeveloperApp: fullDeveloperApp,
}
}

func ToMinDeveloperApps(fullDeveloperApps []FullDeveloperApp) []MinDeveloperApp {
result := make([]MinDeveloperApp, len(fullDeveloperApps))
for i, d := range fullDeveloperApps {
result[i] = ToMinDeveloperApp(d)
}
return result
}
49 changes: 49 additions & 0 deletions api/dbv1/full_playlists.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,52 @@ func (q *Queries) FullPlaylists(ctx context.Context, arg GetPlaylistsParams) ([]

return fullPlaylists, nil
}

type MinPlaylist struct {
ID string `json:"id"`
PlaylistName *string `json:"playlist_name"`
PlaylistOwnerID int32 `json:"playlist_owner_id"`
PlaylistID int32 `json:"playlist_id"`
Artwork SquareImage `json:"artwork"`
Description *string `json:"description"`
PlaylistContents interface{} `json:"playlist_contents"`
IsAlbum bool `json:"is_album"`
IsPrivate bool `json:"is_private"`
FavoriteCount int32 `json:"favorite_count"`
RepostCount int32 `json:"repost_count"`
UserID string `json:"user_id"`
User MinUser `json:"user"`
Tracks []MinTrack `json:"tracks"`
}

func ToMinPlaylist(fullPlaylist FullPlaylist) MinPlaylist {
minTracks := make([]MinTrack, len(fullPlaylist.Tracks))
for i, track := range fullPlaylist.Tracks {
minTracks[i] = ToMinTrack(track)
}

return MinPlaylist{
ID: fullPlaylist.ID,
PlaylistName: fullPlaylist.PlaylistName,
PlaylistOwnerID: fullPlaylist.PlaylistOwnerID,
PlaylistID: fullPlaylist.PlaylistID,
Artwork: fullPlaylist.Artwork,
PlaylistContents: fullPlaylist.PlaylistContents,
Description: nil,
IsAlbum: false,
IsPrivate: false,
FavoriteCount: 0,
RepostCount: 0,
UserID: fullPlaylist.UserID,
User: ToMinUser(fullPlaylist.User),
Tracks: minTracks,
}
}

func ToMinPlaylists(fullPlaylists []FullPlaylist) []MinPlaylist {
result := make([]MinPlaylist, len(fullPlaylists))
for i, playlist := range fullPlaylists {
result[i] = ToMinPlaylist(playlist)
}
return result
}
70 changes: 70 additions & 0 deletions api/dbv1/full_tracks.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package dbv1

import (
"context"
"fmt"

"bridgerton.audius.co/trashid"
"bridgerton.audius.co/utils"
)

type FullTracksParams GetTracksParams
Expand Down Expand Up @@ -61,3 +63,71 @@ func (q *Queries) FullTracks(ctx context.Context, arg GetTracksParams) ([]FullTr

return fullTracks, nil
}

type MinTrack struct {
ID string `json:"id"`
Title *string `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"`
IsOriginalAvailable bool `json:"is_original_available"`
Mood *string `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"`
IsDownloadable bool `json:"is_downloadable"`
PlayCount *int64 `json:"play_count"`
PinnedCommentID *int32 `json:"pinned_comment_id"`
PlaylistsContainingTrack []interface{} `json:"playlists_containing_track"`
AlbumBacklink interface{} `json:"album_backlink"`
IsStreamable bool `json:"is_streamable"`
Permalink string `json:"permalink"`
}

func ToMinTrack(fullTrack FullTrack) MinTrack {
return MinTrack{
ID: fullTrack.ID,
Title: fullTrack.Title,
User: ToMinUser(fullTrack.User),
Artwork: fullTrack.Artwork,
Duration: fullTrack.Duration,
Description: fullTrack.Description,
Genre: fullTrack.Genre,
TrackCid: fullTrack.TrackCid,
PreviewCid: fullTrack.PreviewCid,
OrigFileCid: fullTrack.OrigFileCid,
OrigFilename: fullTrack.OrigFilename,
IsOriginalAvailable: fullTrack.IsOriginalAvailable,
Mood: fullTrack.Mood,
ReleaseDate: fullTrack.ReleaseDate,
RemixOf: fullTrack.RemixOf,
RepostCount: fullTrack.RepostCount,
FavoriteCount: fullTrack.FavoriteCount,
CommentCount: fullTrack.CommentCount,
Tags: fullTrack.Tags,
IsDownloadable: fullTrack.IsDownloadable,
PlayCount: fullTrack.PlayCount,
PinnedCommentID: fullTrack.PinnedCommentID,
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)),
}
}

func ToMinTracks(fullTracks []FullTrack) []MinTrack {
result := make([]MinTrack, len(fullTracks))
for i, track := range fullTracks {
result[i] = ToMinTrack(track)
}
return result
}
80 changes: 80 additions & 0 deletions api/dbv1/full_users.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,83 @@ func squareImageStruct(maybeCids ...*string) SquareImage {
Mirrors: rest,
}
}

type MinUser struct {
ID string `json:"id"`
AlbumCount *int64 `json:"album_count"`
ArtistPickTrackID *string `json:"artist_pick_track_id"`
Bio *string `json:"bio"`
CoverPhoto RectangleImage `json:"cover_photo"`
FolloweeCount *int64 `json:"followee_count"`
FollowerCount *int64 `json:"follower_count"`
Handle *string `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"`
ProfilePicture SquareImage `json:"profile_picture"`
RepostCount *int64 `json:"repost_count"`
TrackCount *int64 `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"`
SupporterCount int32 `json:"supporter_count"`
SupportingCount int32 `json:"supporting_count"`
TotalAudioBalance int32 `json:"total_audio_balance"`
Wallet *string `json:"wallet"`
}

func ToMinUser(fullUser FullUser) MinUser {
return MinUser{
ID: fullUser.ID,
AlbumCount: fullUser.AlbumCount,
ArtistPickTrackID: fullUser.ArtistPickTrackID,
Bio: fullUser.Bio,
CoverPhoto: fullUser.CoverPhoto,
FolloweeCount: fullUser.FolloweeCount,
FollowerCount: fullUser.FollowerCount,
Handle: fullUser.Handle,
IsVerified: fullUser.IsVerified,
TwitterHandle: fullUser.TwitterHandle,
InstagramHandle: fullUser.InstagramHandle,
TiktokHandle: fullUser.TiktokHandle,
VerifiedWithTwitter: fullUser.VerifiedWithTwitter,
VerifiedWithInstagram: fullUser.VerifiedWithInstagram,
VerifiedWithTiktok: fullUser.VerifiedWithTiktok,
Website: fullUser.Website,
Donation: fullUser.Donation,
Location: fullUser.Location,
Name: fullUser.Name,
PlaylistCount: fullUser.PlaylistCount,
ProfilePicture: fullUser.ProfilePicture,
RepostCount: fullUser.RepostCount,
TrackCount: fullUser.TrackCount,
IsDeactivated: fullUser.IsDeactivated,
IsAvailable: fullUser.IsAvailable,
ErcWallet: fullUser.ErcWallet,
SplWallet: fullUser.SplWallet,
SplUsdcPayoutWallet: fullUser.SplUsdcPayoutWallet,
SupporterCount: fullUser.SupporterCount,
SupportingCount: fullUser.SupportingCount,
TotalAudioBalance: fullUser.TotalAudioBalance,
Wallet: fullUser.Wallet,
}
}

func ToMinUsers(fullUsers []FullUser) []MinUser {
result := make([]MinUser, len(fullUsers))
for i, user := range fullUsers {
result[i] = ToMinUser(user)
}
return result
}
12 changes: 8 additions & 4 deletions api/dbv1/get_tracks.sql.go

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

10 changes: 6 additions & 4 deletions api/dbv1/queries/get_tracks.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ SELECT
comment_count,
tags,
title,
track_routes.slug as slug,
-- user,
duration,
is_downloadable,
Expand All @@ -29,7 +30,7 @@ SELECT
pinned_comment_id,
-- album_backlink,
-- access,
blocknumber,
t.blocknumber,
create_date,
t.created_at,
cover_art_sizes,
Expand Down Expand Up @@ -69,8 +70,8 @@ SELECT
stem_of,
-- track_segments, todo: can we just get rid of this now?
t.updated_at,
owner_id as user_id,
is_delete,
t.owner_id as user_id,
t.is_delete,
cover_art,
is_available,
ai_attribution_user_id,
Expand Down Expand Up @@ -109,8 +110,9 @@ SELECT
FROM tracks t
JOIN aggregate_track using (track_id)
LEFT JOIN aggregate_plays on play_item_id = t.track_id
LEFT JOIN track_routes on t.track_id = track_routes.track_id and track_routes.is_current = true
WHERE is_available = true
AND (is_unlisted = false OR owner_id = @my_id)
AND (is_unlisted = false OR t.owner_id = @my_id)
AND (
t.track_id = @track_id
OR t.owner_id = @owner_id
Expand Down
Loading