0
0
Fork 0

ES Modulesに移行

This commit is contained in:
Xeltica 2023-02-25 17:13:07 +09:00
parent 0c3df4245d
commit 69212dd99a
105 changed files with 3154 additions and 3230 deletions

View file

@ -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),
};
};