mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-05 19:26:02 +02:00
Introduce per-instance chart (#4183)
* Introduce per-instance chart * Implement chart view in client * Handle note deleting * More chart srcs * Add drive stats * Improve drive stats * Fix bug * Add icon
This commit is contained in:
@@ -12,6 +12,7 @@ import createFollowRequest from './requests/create';
|
||||
import perUserFollowingChart from '../../services/chart/per-user-following';
|
||||
import { registerOrFetchInstanceDoc } from '../register-or-fetch-instance-doc';
|
||||
import Instance from '../../models/instance';
|
||||
import instanceChart from '../../services/chart/instance';
|
||||
|
||||
export default async function(follower: IUser, followee: IUser, requestId?: string) {
|
||||
// check blocking
|
||||
@@ -108,8 +109,7 @@ export default async function(follower: IUser, followee: IUser, requestId?: stri
|
||||
}
|
||||
});
|
||||
|
||||
// TODO
|
||||
//perInstanceChart.newFollowing();
|
||||
instanceChart.updateFollowing(i.host, true);
|
||||
});
|
||||
} else if (isLocalUser(follower) && isRemoteUser(followee)) {
|
||||
registerOrFetchInstanceDoc(followee.host).then(i => {
|
||||
@@ -119,8 +119,7 @@ export default async function(follower: IUser, followee: IUser, requestId?: stri
|
||||
}
|
||||
});
|
||||
|
||||
// TODO
|
||||
//perInstanceChart.newFollower();
|
||||
instanceChart.updateFollowers(i.host, true);
|
||||
});
|
||||
}
|
||||
//#endregion
|
||||
|
||||
@@ -7,6 +7,9 @@ import renderUndo from '../../remote/activitypub/renderer/undo';
|
||||
import { deliver } from '../../queue';
|
||||
import perUserFollowingChart from '../../services/chart/per-user-following';
|
||||
import Logger from '../../misc/logger';
|
||||
import { registerOrFetchInstanceDoc } from '../register-or-fetch-instance-doc';
|
||||
import Instance from '../../models/instance';
|
||||
import instanceChart from '../../services/chart/instance';
|
||||
|
||||
const logger = new Logger('following/delete');
|
||||
|
||||
@@ -41,6 +44,30 @@ export default async function(follower: IUser, followee: IUser) {
|
||||
});
|
||||
//#endregion
|
||||
|
||||
//#region Update instance stats
|
||||
if (isRemoteUser(follower) && isLocalUser(followee)) {
|
||||
registerOrFetchInstanceDoc(follower.host).then(i => {
|
||||
Instance.update({ _id: i._id }, {
|
||||
$inc: {
|
||||
followingCount: -1
|
||||
}
|
||||
});
|
||||
|
||||
instanceChart.updateFollowing(i.host, false);
|
||||
});
|
||||
} else if (isLocalUser(follower) && isRemoteUser(followee)) {
|
||||
registerOrFetchInstanceDoc(followee.host).then(i => {
|
||||
Instance.update({ _id: i._id }, {
|
||||
$inc: {
|
||||
followersCount: -1
|
||||
}
|
||||
});
|
||||
|
||||
instanceChart.updateFollowers(i.host, false);
|
||||
});
|
||||
}
|
||||
//#endregion
|
||||
|
||||
perUserFollowingChart.update(follower, followee, false);
|
||||
|
||||
// Publish unfollow event
|
||||
|
||||
Reference in New Issue
Block a user