mirror of
https://github.com/zadam/trilium.git
synced 2026-02-21 13:14:26 +01:00
chore(core): port stats route
This commit is contained in:
parent
da7a61a8b6
commit
e9214d84b7
@ -50,7 +50,6 @@ import setupApiRoute from "./api/setup.js";
|
||||
import similarNotesRoute from "./api/similar_notes.js";
|
||||
import specialNotesRoute from "./api/special_notes.js";
|
||||
import sqlRoute from "./api/sql.js";
|
||||
import statsRoute from "./api/stats.js";
|
||||
import syncApiRoute from "./api/sync.js";
|
||||
import systemInfoRoute from "./api/system_info.js";
|
||||
import totp from './api/totp.js';
|
||||
@ -287,8 +286,6 @@ function register(app: express.Application) {
|
||||
apiRoute(PST, "/api/relation-map", relationMapApiRoute.getRelationMap);
|
||||
asyncApiRoute(GET, "/api/similar-notes/:noteId", similarNotesRoute.getSimilarNotes);
|
||||
asyncApiRoute(GET, "/api/backend-log", backendLogRoute.getBackendLog);
|
||||
apiRoute(GET, "/api/stats/note-size/:noteId", statsRoute.getNoteSize);
|
||||
apiRoute(GET, "/api/stats/subtree-size/:noteId", statsRoute.getSubtreeSize);
|
||||
route(GET, "/api/fonts", [auth.checkApiAuthOrElectron], fontsRoute.getFontCss);
|
||||
apiRoute(PST, "/api/other/render-markdown", otherRoute.renderMarkdown);
|
||||
apiRoute(PST, "/api/other/to-markdown", otherRoute.toMarkdown);
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
import sql from "../../services/sql.js";
|
||||
import becca from "../../becca/becca.js";
|
||||
import type { Request } from "express";
|
||||
import { NoteSizeResponse, SubtreeSizeResponse } from "@triliumnext/commons";
|
||||
import { getSql } from "../../services/sql/index.js";
|
||||
|
||||
function getNoteSize(req: Request) {
|
||||
const { noteId } = req.params;
|
||||
|
||||
const blobSizes = sql.getMap<string, number>(
|
||||
const blobSizes = getSql().getMap<string, number>(
|
||||
`
|
||||
SELECT blobs.blobId, LENGTH(content)
|
||||
FROM blobs
|
||||
@ -28,9 +28,8 @@ function getNoteSize(req: Request) {
|
||||
|
||||
function getSubtreeSize(req: Request) {
|
||||
const note = becca.getNoteOrThrow(req.params.noteId);
|
||||
|
||||
const subTreeNoteIds = note.getSubtreeNoteIds();
|
||||
|
||||
const sql = getSql();
|
||||
sql.fillParamList(subTreeNoteIds);
|
||||
|
||||
const blobSizes = sql.getMap<string, number>(`
|
||||
@ -8,6 +8,7 @@ import recentNotesRoute from "./api/recent_notes";
|
||||
import otherRoute from "./api/others";
|
||||
import branchesApiRoute from "./api/branches";
|
||||
import appInfoRoute from "./api/app_info";
|
||||
import statsRoute from "./api/stats";
|
||||
import AbstractBeccaEntity from "../becca/entities/abstract_becca_entity";
|
||||
|
||||
// TODO: Deduplicate with routes.ts
|
||||
@ -71,6 +72,9 @@ export function buildSharedApiRoutes(apiRoute: any) {
|
||||
apiRoute(GET, "/api/keyboard-actions", keysApiRoute.getKeyboardActions);
|
||||
apiRoute(GET, "/api/keyboard-shortcuts-for-notes", keysApiRoute.getShortcutsForNotes);
|
||||
|
||||
apiRoute(GET, "/api/stats/note-size/:noteId", statsRoute.getNoteSize);
|
||||
apiRoute(GET, "/api/stats/subtree-size/:noteId", statsRoute.getSubtreeSize);
|
||||
|
||||
apiRoute(GET, "/api/app-info", appInfoRoute.getAppInfo);
|
||||
apiRoute(GET, "/api/other/icon-usage", otherRoute.getIconUsage);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user