Skip to content

Commit fc1a70c

Browse files
committed
refactor: remove count parameter from song retrieval queries and replace with limit for consistency
1 parent 3ec650a commit fc1a70c

File tree

5 files changed

+6
-7
lines changed

5 files changed

+6
-7
lines changed

apps/backend/src/app.module.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ import { UserModule } from './user/user.module';
7575
UserModule,
7676
AuthModule.forRootAsync(),
7777
FileModule.forRootAsync(),
78-
SongBrowserModule,
7978
SeedModule.forRoot(),
8079
EmailLoginModule,
8180
MailingModule,

apps/backend/src/song/song.controller.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ export class SongController {
9494
@Query() query: PageQueryDTO,
9595
@Query('q') q?: 'featured' | 'recent' | 'categories' | 'random',
9696
@Param('id') id?: string,
97-
@Query('count') count?: string,
9897
@Query('category') category?: string,
9998
): Promise<SongPreviewDto[] | Record<string, number>> {
10099
if (q) {
@@ -109,12 +108,11 @@ export class SongController {
109108
}
110109
return await this.songBrowserService.getCategories();
111110
case 'random': {
112-
const countInt = parseInt(count);
113-
if (isNaN(countInt) || countInt < 1 || countInt > 10) {
111+
if (query.limit && (query.limit < 1 || query.limit > 10)) {
114112
throw new BadRequestException('Invalid query parameters');
115113
}
116114
return await this.songBrowserService.getRandomSongs(
117-
countInt,
115+
query.limit ?? 1,
118116
category,
119117
);
120118
}

apps/backend/src/song/song.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { FileModule } from '@server/file/file.module';
88
import { UserModule } from '@server/user/user.module';
99

1010
import { MySongsController } from './my-songs/my-songs.controller';
11+
import { SongBrowserService } from './song-browser/song-browser.service';
1112
import { SongUploadService } from './song-upload/song-upload.service';
1213
import { SongWebhookService } from './song-webhook/song-webhook.service';
1314
import { SongController } from './song.controller';
@@ -24,6 +25,7 @@ import { SongService } from './song.service';
2425
SongService,
2526
SongUploadService,
2627
SongWebhookService,
28+
SongBrowserService,
2729
{
2830
inject : [ConfigService],
2931
provide : 'DISCORD_WEBHOOK_URL',

apps/frontend/src/modules/shared/components/layout/RandomSongButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const RandomSongButton = () => {
2222
{
2323
params: {
2424
q : 'random',
25-
count: 1,
25+
limit: 1,
2626
},
2727
},
2828
);

apps/frontend/src/modules/song/components/SongPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export async function SongPage({ id }: { id: string }) {
4545
{
4646
params: {
4747
q : 'random',
48-
count : 4,
48+
limit : 4,
4949
category: song.category,
5050
},
5151
},

0 commit comments

Comments
 (0)