tangled
alpha
login
or
join now
t1c.dev
/
rocksky
forked from
rocksky.app/rocksky
2
fork
atom
A decentralized music tracking and discovery platform built on AT Protocol 🎵
2
fork
atom
overview
issues
pulls
pipelines
Include artist genres in scrobbles response
tsiry-sandratraina.com
1 month ago
9fe5b52c
164f3ace
+20
-15
1 changed file
expand all
collapse all
unified
split
apps
api
src
xrpc
app
rocksky
scrobble
getScrobbles.ts
+20
-15
apps/api/src/xrpc/app/rocksky/scrobble/getScrobbles.ts
···
10
10
import type { SelectScrobble } from "schema/scrobbles";
11
11
import type { SelectTrack } from "schema/tracks";
12
12
import type { SelectUser } from "schema/users";
13
13
+
import { SelectArtist } from "schema/artists";
13
14
14
15
export default function (server: Server, ctx: Context) {
15
16
const getScrobbles = (params: QueryParams) =>
···
83
84
.select()
84
85
.from(tables.scrobbles)
85
86
.leftJoin(tables.tracks, eq(tables.scrobbles.trackId, tables.tracks.id))
86
86
-
.leftJoin(tables.users, eq(tables.scrobbles.userId, tables.users.id));
87
87
+
.leftJoin(tables.users, eq(tables.scrobbles.userId, tables.users.id))
88
88
+
.leftJoin(tables.artists, eq(tables.scrobbles.artistId, tables.artists.id));
87
89
88
90
const query = filterDids
89
91
? baseQuery.where(inArray(tables.users.did, filterDids))
···
137
139
data: Scrobbles,
138
140
): Effect.Effect<{ scrobbles: ScrobbleViewBasic[] }, never> => {
139
141
return Effect.sync(() => ({
140
140
-
scrobbles: data.map(({ scrobbles, tracks, users, liked, likesCount }) => ({
141
141
-
...R.omit(["albumArt", "id", "lyrics"])(tracks),
142
142
-
cover: tracks.albumArt,
143
143
-
date: scrobbles.timestamp.toISOString(),
144
144
-
user: users.handle,
145
145
-
userDisplayName: users.displayName,
146
146
-
userAvatar: users.avatar,
147
147
-
uri: scrobbles.uri,
148
148
-
tags: [],
149
149
-
id: scrobbles.id,
150
150
-
trackUri: tracks.uri,
151
151
-
likesCount,
152
152
-
liked,
153
153
-
})),
142
142
+
scrobbles: data.map(
143
143
+
({ scrobbles, tracks, users, artists, liked, likesCount }) => ({
144
144
+
...R.omit(["albumArt", "id", "lyrics"])(tracks),
145
145
+
cover: tracks.albumArt,
146
146
+
date: scrobbles.timestamp.toISOString(),
147
147
+
user: users.handle,
148
148
+
userDisplayName: users.displayName,
149
149
+
userAvatar: users.avatar,
150
150
+
uri: scrobbles.uri,
151
151
+
tags: artists?.genres,
152
152
+
id: scrobbles.id,
153
153
+
trackUri: tracks.uri,
154
154
+
likesCount,
155
155
+
liked,
156
156
+
}),
157
157
+
),
154
158
}));
155
159
};
156
160
···
158
162
scrobbles: SelectScrobble;
159
163
tracks: SelectTrack;
160
164
users: SelectUser;
165
165
+
artists: SelectArtist;
161
166
liked: boolean;
162
167
likesCount: number;
163
168
}[];