A decentralized music tracking and discovery platform built on AT Protocol 🎵

Exclude Various Artists from top artists

+10 -2
+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 - import { count, desc, sql, and, gte, lte, inArray } from "drizzle-orm"; 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 - .where(dateConditions.length > 0 ? and(...dateConditions) : undefined) 66 + .leftJoin( 67 + tables.artists, 68 + sql`${tables.scrobbles.artistId} = ${tables.artists.id}`, 69 + ) 70 + .where( 71 + dateConditions.length > 0 72 + ? and(...dateConditions, ne(tables.artists.name, "Various Artists")) 73 + : ne(tables.artists.name, "Various Artists"), 74 + ) 67 75 .groupBy(tables.scrobbles.artistId) 68 76 .orderBy(desc(sql`count(${tables.scrobbles.id})`)) 69 77 .limit(limit)