From 84ae3a4e229314a3e75764ba794546800dcf9244 Mon Sep 17 00:00:00 2001 From: Tsiry Sandratraina Date: Wed, 24 Sep 2025 19:44:02 +0300 Subject: [PATCH] feat: add pagination parameters to get_artist_listeners query --- apps/api/lexicons/artist/getArtistListeners.json | 8 ++++++++ apps/api/pkl/defs/artist/getArtistListeners.pkl | 6 ++++++ apps/api/src/lexicon/lexicons.ts | 8 ++++++++ .../types/app/rocksky/artist/getArtistListeners.ts | 4 ++++ .../api/src/xrpc/app/rocksky/artist/getArtistListeners.ts | 4 ++++ 5 files changed, 30 insertions(+) diff --git a/apps/api/lexicons/artist/getArtistListeners.json b/apps/api/lexicons/artist/getArtistListeners.json index b7eb3b9b..0d66f764 100644 --- a/apps/api/lexicons/artist/getArtistListeners.json +++ b/apps/api/lexicons/artist/getArtistListeners.json @@ -15,6 +15,14 @@ "type": "string", "description": "The URI of the artist to retrieve listeners from", "format": "at-uri" + }, + "offset": { + "type": "integer", + "description": "Number of items to skip before returning results" + }, + "limit": { + "type": "integer", + "description": "Maximum number of results to return" } } }, diff --git a/apps/api/pkl/defs/artist/getArtistListeners.pkl b/apps/api/pkl/defs/artist/getArtistListeners.pkl index f31809a2..5e567da7 100644 --- a/apps/api/pkl/defs/artist/getArtistListeners.pkl +++ b/apps/api/pkl/defs/artist/getArtistListeners.pkl @@ -13,6 +13,12 @@ defs = new Mapping { description = "The URI of the artist to retrieve listeners from" format = "at-uri" } + ["offset"] = new IntegerType { + description = "Number of items to skip before returning results" + } + ["limit"] = new IntegerType { + description = "Maximum number of results to return" + } } } output { diff --git a/apps/api/src/lexicon/lexicons.ts b/apps/api/src/lexicon/lexicons.ts index 21099146..27bca259 100644 --- a/apps/api/src/lexicon/lexicons.ts +++ b/apps/api/src/lexicon/lexicons.ts @@ -1208,6 +1208,14 @@ export const schemaDict = { description: 'The URI of the artist to retrieve listeners from', format: 'at-uri', }, + offset: { + type: 'integer', + description: 'Number of items to skip before returning results', + }, + limit: { + type: 'integer', + description: 'Maximum number of results to return', + }, }, }, output: { diff --git a/apps/api/src/lexicon/types/app/rocksky/artist/getArtistListeners.ts b/apps/api/src/lexicon/types/app/rocksky/artist/getArtistListeners.ts index 62b85f7d..d2a3323c 100644 --- a/apps/api/src/lexicon/types/app/rocksky/artist/getArtistListeners.ts +++ b/apps/api/src/lexicon/types/app/rocksky/artist/getArtistListeners.ts @@ -12,6 +12,10 @@ import type * as AppRockskyArtistDefs from './defs' export interface QueryParams { /** The URI of the artist to retrieve listeners from */ uri: string + /** Number of items to skip before returning results */ + offset?: number + /** Maximum number of results to return */ + limit?: number } export type InputSchema = undefined diff --git a/apps/api/src/xrpc/app/rocksky/artist/getArtistListeners.ts b/apps/api/src/xrpc/app/rocksky/artist/getArtistListeners.ts index 3214ccf6..0ccd81da 100644 --- a/apps/api/src/xrpc/app/rocksky/artist/getArtistListeners.ts +++ b/apps/api/src/xrpc/app/rocksky/artist/getArtistListeners.ts @@ -39,6 +39,10 @@ const retrieve = ({ try: () => ctx.analytics.post("library.getArtistListeners", { artist_id: params.uri, + pagination: { + skip: params.offset || 0, + take: params.limit || 100, + }, }), catch: (error) => new Error(`Failed to retrieve artist's listeners: ${error}`), -- 2.51.2