mirror of
https://github.com/svemagie/indiekit-endpoint-activitypub.git
synced 2026-04-02 15:44:58 +02:00
Replace unbounded ap_kv MongoDB collection (169K docs, 49MB) with Redis: - Fedify KV store uses @fedify/redis RedisKvStore (native TTL support) - Plugin cache (fedidb, batch-refollow state, migration flags) uses new redis-cache.js utility with indiekit: key prefix - All controllers updated to remove kvCollection parameter passing - Addresses OOM kills caused by ap_kv growing ~14K entries/day
60 lines
1.9 KiB
JavaScript
60 lines
1.9 KiB
JavaScript
/**
|
|
* Dashboard controller — shows follower/following counts and recent activity.
|
|
*/
|
|
|
|
import { getBatchRefollowStatus } from "../batch-refollow.js";
|
|
|
|
export function dashboardController(mountPath) {
|
|
return async (request, response, next) => {
|
|
try {
|
|
const { application } = request.app.locals;
|
|
const followersCollection = application?.collections?.get("ap_followers");
|
|
const followingCollection = application?.collections?.get("ap_following");
|
|
const activitiesCollection =
|
|
application?.collections?.get("ap_activities");
|
|
const featuredCollection = application?.collections?.get("ap_featured");
|
|
const featuredTagsCollection =
|
|
application?.collections?.get("ap_featured_tags");
|
|
|
|
const followerCount = followersCollection
|
|
? await followersCollection.countDocuments()
|
|
: 0;
|
|
const followingCount = followingCollection
|
|
? await followingCollection.countDocuments()
|
|
: 0;
|
|
const pinnedCount = featuredCollection
|
|
? await featuredCollection.countDocuments()
|
|
: 0;
|
|
const tagCount = featuredTagsCollection
|
|
? await featuredTagsCollection.countDocuments()
|
|
: 0;
|
|
|
|
const recentActivities = activitiesCollection
|
|
? await activitiesCollection
|
|
.find()
|
|
.sort({ receivedAt: -1 })
|
|
.limit(10)
|
|
.toArray()
|
|
: [];
|
|
|
|
// Get batch re-follow status for the progress section
|
|
const refollowStatus = await getBatchRefollowStatus({
|
|
ap_following: followingCollection,
|
|
});
|
|
|
|
response.render("activitypub-dashboard", {
|
|
title: response.locals.__("activitypub.title"),
|
|
followerCount,
|
|
followingCount,
|
|
pinnedCount,
|
|
tagCount,
|
|
recentActivities,
|
|
refollowStatus,
|
|
mountPath,
|
|
});
|
|
} catch (error) {
|
|
next(error);
|
|
}
|
|
};
|
|
}
|