forked from pinks/eris
feat: tagcount endpoint
removes tagCountMap from user endpoint, returns it only via admin-only endpoint
This commit is contained in:
parent
5b61576315
commit
af7b370321
|
@ -5,6 +5,7 @@ import { generationStore } from "../app/generationStore.ts";
|
||||||
import { globalStats } from "../app/globalStats.ts";
|
import { globalStats } from "../app/globalStats.ts";
|
||||||
import { getUserDailyStats } from "../app/userDailyStatsStore.ts";
|
import { getUserDailyStats } from "../app/userDailyStatsStore.ts";
|
||||||
import { getUserStats } from "../app/userStatsStore.ts";
|
import { getUserStats } from "../app/userStatsStore.ts";
|
||||||
|
import { withAdmin } from "./withUser.ts";
|
||||||
|
|
||||||
const STATS_INTERVAL_MIN = 3;
|
const STATS_INTERVAL_MIN = 3;
|
||||||
|
|
||||||
|
@ -91,11 +92,31 @@ export const statsRoute = createPathFilter({
|
||||||
data: {
|
data: {
|
||||||
imageCount: stats.imageCount,
|
imageCount: stats.imageCount,
|
||||||
pixelCount: stats.pixelCount,
|
pixelCount: stats.pixelCount,
|
||||||
|
timestamp: stats.timestamp,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
"users/{userId}/tagcount": createMethodFilter({
|
||||||
|
GET: createEndpoint(
|
||||||
|
{ query: { sessionId: { type: "string" } }, body: null },
|
||||||
|
async ({ params, query }) => {
|
||||||
|
return withAdmin(query, async () => {
|
||||||
|
const userId = Number(params.userId);
|
||||||
|
const stats = await getUserStats(userId);
|
||||||
|
return {
|
||||||
|
status: 200,
|
||||||
|
body: {
|
||||||
|
type: "application/json",
|
||||||
|
data: {
|
||||||
tagCountMap: stats.tagCountMap,
|
tagCountMap: stats.tagCountMap,
|
||||||
timestamp: stats.timestamp,
|
timestamp: stats.timestamp,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
}),
|
}),
|
||||||
|
|
Loading…
Reference in New Issue