mirror of
https://github.com/chuot/rdio-scanner.git
synced 2026-08-13 08:33:00 -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';
|
||||
|
||||
if (Meteor.isServer) {
|
||||
createApiHandler();
|
||||
}
|
||||
|
||||
function createApiHandler(): void {
|
||||
WebApp.connectHandlers.use('/talkgroups', (req: IncomingMessage, res: ServerResponse) => {
|
||||
if (req.method === 'POST') {
|
||||
const form = new Form();
|
||||
|
|
|
|||
|
|
@ -6,6 +6,15 @@ import { Calls } from '../../../imports/collections/calls';
|
|||
import { Call } from '../../../imports/models/call';
|
||||
|
||||
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) => {
|
||||
if (req.method === 'POST') {
|
||||
const form = new Form();
|
||||
|
|
@ -66,8 +75,6 @@ if (Meteor.isServer) {
|
|||
|
||||
form.parse(req);
|
||||
|
||||
pruneCalls();
|
||||
|
||||
} else {
|
||||
res.writeHead(404);
|
||||
res.end();
|
||||
|
|
@ -75,12 +82,8 @@ if (Meteor.isServer) {
|
|||
});
|
||||
}
|
||||
|
||||
function base64Encode(value: any): string {
|
||||
return Buffer.from(value, 'binary').toString('base64');
|
||||
}
|
||||
|
||||
function urlEncode(mimeType: string, value: any): string {
|
||||
return `data:${mimeType};base64,${base64Encode(value)}`;
|
||||
function createPruneCallsTimer(): void {
|
||||
setInterval(() => pruneCalls(), 90000);
|
||||
}
|
||||
|
||||
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