From 017c3a908c0fe5fd8a4e202748361b10c0655b9b Mon Sep 17 00:00:00 2001 From: Anisha Keshavan Date: Wed, 7 Sep 2016 11:53:35 -0700 Subject: [PATCH] rf: moved startup function out of publication to startup --- imports/api/publications.js | 15 --------------- imports/startup/fill_empty_db.js | 24 ++++++++++++++++++++++++ imports/ui/qc.js | 2 +- server/main.js | 1 + 4 files changed, 26 insertions(+), 16 deletions(-) create mode 100644 imports/startup/fill_empty_db.js diff --git a/imports/api/publications.js b/imports/api/publications.js index da357e1..890bbc8 100644 --- a/imports/api/publications.js +++ b/imports/api/publications.js @@ -5,21 +5,6 @@ if (Meteor.isServer) { // Only publish tasks that are public or belong to the current user - Meteor.startup(function () { - //Subjects.remove({}) - if (Subjects.find().count() === 0) { - //load the json from here: https://www.dropbox.com/s/enb5zemvmu2oqgw/data.json?dl=0 - var source_json = "https://dl.dropboxusercontent.com/s/vnohn5nh9ho3j8a/data_rf.json?dl=0" - //console.log(HTTP.get(source_json).content) - myobject = JSON.parse(HTTP.get(source_json).content) - //console.log("my object is", myobject.length) - myobject.forEach(function(val,idx,array){ - Subjects.insert(val) - }) - - } - }); - Meteor.publish('get_qc_doc', function tasksPublication(entry_type, name) { console.log("publishing", entry_type, name) return Subjects.find({"entry_type": entry_type, "name": name}); diff --git a/imports/startup/fill_empty_db.js b/imports/startup/fill_empty_db.js new file mode 100644 index 0000000..ec563ac --- /dev/null +++ b/imports/startup/fill_empty_db.js @@ -0,0 +1,24 @@ +import {Subjects} from "../api/module_tables.js" + +if (Meteor.isServer) { + // This code only runs on the server + // Only publish tasks that are public or belong to the current user + + + Meteor.startup(function () { + //Subjects.remove({}) + console.log("in metero startup function") + if (Subjects.find().count() === 0) { + //load the json from here: https://www.dropbox.com/s/enb5zemvmu2oqgw/data.json?dl=0 + var source_json = "https://dl.dropboxusercontent.com/s/vnohn5nh9ho3j8a/data_rf.json?dl=0" + //console.log(HTTP.get(source_json).content) + myobject = JSON.parse(HTTP.get(source_json).content) + //console.log("my object is", myobject.length) + myobject.forEach(function(val,idx,array){ + Subjects.insert(val) + }) + + } + }); + + } \ No newline at end of file diff --git a/imports/ui/qc.js b/imports/ui/qc.js index 0868872..148dadc 100644 --- a/imports/ui/qc.js +++ b/imports/ui/qc.js @@ -11,7 +11,7 @@ import "./painter.js" //var staticURL = "http://127.0.0.1:3002/" -var staticURL = "https://dl.dropboxusercontent.com/u/9020198/data/" +//var staticURL = "https://dl.dropboxusercontent.com/u/9020198/data/" use_peerJS = true diff --git a/server/main.js b/server/main.js index 09a2728..6aa9baa 100644 --- a/server/main.js +++ b/server/main.js @@ -1,2 +1,3 @@ import '../imports/api/module_tables.js'; import '../imports/api/table_utils.js'; +import '../imports/startup/fill_empty_db.js';