ES Modulesに移行
This commit is contained in:
parent
0c3df4245d
commit
69212dd99a
105 changed files with 3154 additions and 3230 deletions
|
@ -1,9 +1,9 @@
|
|||
import { User } from '../models/entities/user';
|
||||
import { toSignedString } from '../../common/functions/to-signed-string';
|
||||
import {Count} from '../models/count';
|
||||
import {api} from '../services/misskey';
|
||||
import {Score} from '../../common/types/score';
|
||||
import {MiUser} from './update-score';
|
||||
import { User } from '../models/entities/user.js';
|
||||
import { toSignedString } from '../../common/functions/to-signed-string.js';
|
||||
import {Count} from '../models/count.js';
|
||||
import {api} from '../services/misskey.js';
|
||||
import {Score} from '../../common/types/score.js';
|
||||
import {MiUser} from './update-score.js';
|
||||
|
||||
/**
|
||||
* ユーザーのスコアを取得します。
|
||||
|
@ -11,15 +11,15 @@ import {MiUser} from './update-score';
|
|||
* @returns ユーザーのスコア
|
||||
*/
|
||||
export const getScores = async (user: User): Promise<Score> => {
|
||||
// TODO 毎回取ってくるのも微妙なので、ある程度キャッシュしたいかも
|
||||
const miUser = await api<MiUser>(user.host, 'users/show', { username: user.username }, user.token);
|
||||
// TODO 毎回取ってくるのも微妙なので、ある程度キャッシュしたいかも
|
||||
const miUser = await api<MiUser>(user.host, 'users/show', { username: user.username }, user.token);
|
||||
|
||||
return {
|
||||
notesCount: miUser.notesCount,
|
||||
followingCount: miUser.followingCount,
|
||||
followersCount: miUser.followersCount,
|
||||
...getDelta(user, miUser),
|
||||
};
|
||||
return {
|
||||
notesCount: miUser.notesCount,
|
||||
followingCount: miUser.followingCount,
|
||||
followersCount: miUser.followersCount,
|
||||
...getDelta(user, miUser),
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -29,9 +29,9 @@ export const getScores = async (user: User): Promise<Score> => {
|
|||
* @returns ユーザーのスコア差分
|
||||
*/
|
||||
export const getDelta = (user: User, count: Count) => {
|
||||
return {
|
||||
notesDelta: toSignedString(count.notesCount - user.prevNotesCount),
|
||||
followingDelta: toSignedString(count.followingCount - user.prevFollowingCount),
|
||||
followersDelta: toSignedString(count.followersCount - user.prevFollowersCount),
|
||||
};
|
||||
return {
|
||||
notesDelta: toSignedString(count.notesCount - user.prevNotesCount),
|
||||
followingDelta: toSignedString(count.followingCount - user.prevFollowingCount),
|
||||
followersDelta: toSignedString(count.followersCount - user.prevFollowersCount),
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue