mirror of
https://github.com/chuot/rdio-scanner.git
synced 2026-08-13 16:33:01 -06:00
Schedule calls pruning instead of pruning at each upload
This commit is contained in:
parent
2a717b7afb
commit
2353cfdf59
|
|
@ -7,6 +7,10 @@ import { System } from '../../../imports/models/system';
|
||||||
import { Talkgroup } from '../../../imports/models/talkgroup';
|
import { Talkgroup } from '../../../imports/models/talkgroup';
|
||||||
|
|
||||||
if (Meteor.isServer) {
|
if (Meteor.isServer) {
|
||||||
|
createApiHandler();
|
||||||
|
}
|
||||||
|
|
||||||
|
function createApiHandler(): void {
|
||||||
WebApp.connectHandlers.use('/talkgroups', (req: IncomingMessage, res: ServerResponse) => {
|
WebApp.connectHandlers.use('/talkgroups', (req: IncomingMessage, res: ServerResponse) => {
|
||||||
if (req.method === 'POST') {
|
if (req.method === 'POST') {
|
||||||
const form = new Form();
|
const form = new Form();
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,15 @@ import { Calls } from '../../../imports/collections/calls';
|
||||||
import { Call } from '../../../imports/models/call';
|
import { Call } from '../../../imports/models/call';
|
||||||
|
|
||||||
if (Meteor.isServer) {
|
if (Meteor.isServer) {
|
||||||
|
createApiHandler();
|
||||||
|
createPruneCallsTimer();
|
||||||
|
}
|
||||||
|
|
||||||
|
function base64Encode(value: any): string {
|
||||||
|
return Buffer.from(value, 'binary').toString('base64');
|
||||||
|
}
|
||||||
|
|
||||||
|
function createApiHandler(): void {
|
||||||
WebApp.connectHandlers.use('/upload', (req: IncomingMessage, res: ServerResponse) => {
|
WebApp.connectHandlers.use('/upload', (req: IncomingMessage, res: ServerResponse) => {
|
||||||
if (req.method === 'POST') {
|
if (req.method === 'POST') {
|
||||||
const form = new Form();
|
const form = new Form();
|
||||||
|
|
@ -66,8 +75,6 @@ if (Meteor.isServer) {
|
||||||
|
|
||||||
form.parse(req);
|
form.parse(req);
|
||||||
|
|
||||||
pruneCalls();
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
res.writeHead(404);
|
res.writeHead(404);
|
||||||
res.end();
|
res.end();
|
||||||
|
|
@ -75,12 +82,8 @@ if (Meteor.isServer) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function base64Encode(value: any): string {
|
function createPruneCallsTimer(): void {
|
||||||
return Buffer.from(value, 'binary').toString('base64');
|
setInterval(() => pruneCalls(), 90000);
|
||||||
}
|
|
||||||
|
|
||||||
function urlEncode(mimeType: string, value: any): string {
|
|
||||||
return `data:${mimeType};base64,${base64Encode(value)}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPruneDays(): number | null {
|
function getPruneDays(): number | null {
|
||||||
|
|
@ -102,3 +105,7 @@ function pruneCalls(): void {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function urlEncode(mimeType: string, value: any): string {
|
||||||
|
return `data:${mimeType};base64,${base64Encode(value)}`;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue