Example #1
0
 'search_courses': function(text: string, results_per_page: number, page_no: number) {
   var courseAsync = Meteor.wrapAsync(course_search);
   var result;
   var error;
   courseAsync(text, results_per_page, page_no, function(res, err) {
     if(err) {
       result = null;
       error = err;
     }
     else {
       result = res;
       error = null;
     }
   });
   if(error) {
     throw new Meteor.Error("Search Error");
   }
   else {
     return result;
   }
 }
Example #2
0
import * as crypto from 'crypto';
import * as _ from 'lodash';
import * as moment from 'moment'
import * as parse from 'csv-parse';

import {
    OtpImportLogCollection, OtpIncomeOrExpense, OtpImportLogEntry, OtpSchemas, OtpCsvLine,
    OtpCsvLineHashCollection
} from "../index.ts";
import {Logger} from "../../../startup/server/Logger";

Meteor.publish('otp.importlogs', () => OtpImportLogCollection.find({}));
Meteor.publish('otp.importLogs.single', (id) => OtpImportLogCollection.find(id));

const parseSync = Meteor.wrapAsync(parse);

function digest(line: OtpCsvLine): string {
    const hash = crypto.createHash('sha256');
    hash.update(line.raw.join(","));
    return hash.digest('hex');
}

Meteor.methods({
    'otp.import-csv': function (csvText) {
        check(csvText, String);
        const logContext = Logger.withContext(this, {type: 'otp.import-csv'});
        logContext.info({event: 'start'});

        logContext.info({event: 'parsing-start'});
        var parsed;