Skip to content

Commit

Permalink
rf: moved startup function out of publication to startup
Browse files Browse the repository at this point in the history
  • Loading branch information
akeshavan committed Sep 7, 2016
1 parent 3215fe3 commit 017c3a9
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
15 changes: 0 additions & 15 deletions imports/api/publications.js
Original file line number Diff line number Diff line change
Expand Up @@ -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});
Expand Down
24 changes: 24 additions & 0 deletions imports/startup/fill_empty_db.js
Original file line number Diff line number Diff line change
@@ -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)
})

}
});

}
2 changes: 1 addition & 1 deletion imports/ui/qc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
1 change: 1 addition & 0 deletions server/main.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import '../imports/api/module_tables.js';
import '../imports/api/table_utils.js';
import '../imports/startup/fill_empty_db.js';

0 comments on commit 017c3a9

Please sign in to comment.