mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-20 09:05:09 +01:00
0d7d1091c8
Co-authored-by: osamu <46447427+sam-osamu@users.noreply.github.com>
40 lines
986 B
TypeScript
40 lines
986 B
TypeScript
/*
|
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
import { Inject, Injectable } from '@nestjs/common';
|
|
import { DI } from '@/di-symbols.js';
|
|
import { type FlashsRepository } from '@/models/_.js';
|
|
|
|
/**
|
|
* MisskeyPlay関係のService
|
|
*/
|
|
@Injectable()
|
|
export class FlashService {
|
|
constructor(
|
|
@Inject(DI.flashsRepository)
|
|
private flashRepository: FlashsRepository,
|
|
) {
|
|
}
|
|
|
|
/**
|
|
* 人気のあるPlay一覧を取得する.
|
|
*/
|
|
public async featured(opts?: { offset?: number, limit: number }) {
|
|
const builder = this.flashRepository.createQueryBuilder('flash')
|
|
.andWhere('flash.likedCount > 0')
|
|
.andWhere('flash.visibility = :visibility', { visibility: 'public' })
|
|
.addOrderBy('flash.likedCount', 'DESC')
|
|
.addOrderBy('flash.updatedAt', 'DESC')
|
|
.addOrderBy('flash.id', 'DESC');
|
|
|
|
if (opts?.offset) {
|
|
builder.skip(opts.offset);
|
|
}
|
|
|
|
builder.take(opts?.limit ?? 10);
|
|
|
|
return await builder.getMany();
|
|
}
|
|
}
|