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
Exclude Various Artists from top artists
tsiry-sandratraina.com
1 month ago
c32e8956
4a4c80af
+10
-2
1 changed file
expand all
collapse all
unified
split
apps
api
src
xrpc
app
rocksky
charts
getTopArtists.ts
+10
-2
apps/api/src/xrpc/app/rocksky/charts/getTopArtists.ts
···
1
1
import type { Context } from "context";
2
2
import { consola } from "consola";
3
3
-
import { count, desc, sql, and, gte, lte, inArray } from "drizzle-orm";
3
3
+
import { count, desc, sql, and, gte, lte, inArray, ne } from "drizzle-orm";
4
4
import { Effect, pipe } from "effect";
5
5
import type { Server } from "lexicon";
6
6
import type { ArtistViewBasic } from "lexicon/types/app/rocksky/artist/defs";
···
63
63
scrobbles: count(tables.scrobbles.id).as("scrobbles"),
64
64
})
65
65
.from(tables.scrobbles)
66
66
-
.where(dateConditions.length > 0 ? and(...dateConditions) : undefined)
66
66
+
.leftJoin(
67
67
+
tables.artists,
68
68
+
sql`${tables.scrobbles.artistId} = ${tables.artists.id}`,
69
69
+
)
70
70
+
.where(
71
71
+
dateConditions.length > 0
72
72
+
? and(...dateConditions, ne(tables.artists.name, "Various Artists"))
73
73
+
: ne(tables.artists.name, "Various Artists"),
74
74
+
)
67
75
.groupBy(tables.scrobbles.artistId)
68
76
.orderBy(desc(sql`count(${tables.scrobbles.id})`))
69
77
.limit(limit)