forked from oaeproject/OAE-model-loader
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate.js
More file actions
66 lines (58 loc) · 1.99 KB
/
generate.js
File metadata and controls
66 lines (58 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
var general = require("./api/general.js");
var user = require("./api/user.model.js");
var contacts = require("./api/contacts.model.js");
var world = require("./api/world.model.js");
//////////////////////////////////////
// OVERALL CONFIGURATION PARAMETERS //
//////////////////////////////////////
var SCRIPT_FOLDER = "scripts";
var TOTAL_BATCHES = 5;
var USERS_PER_BATCH = 10; //1000;
var WORLDS_PER_BATCH = 25; //2500;
var CONTENT_PER_BATCH = 0;
var COLLECTIONS_PER_BATCH = 0;
////////////////////
// KICK OFF BATCH //
////////////////////
var batches = [];
var run = function(){
for (var i = 0; i < TOTAL_BATCHES; i++){
var batch = generateBatch(i);
// Write users to file
general.writeFileIntoArray("./" + SCRIPT_FOLDER + "/users/" + i + ".txt", batch.users);
// Write contacts to file
general.writeFileIntoArray("./" + SCRIPT_FOLDER + "/contacts/" + i + ".txt", batch.contacts);
// Write worlds to file
general.writeFileIntoArray("./" + SCRIPT_FOLDER + "/worlds/" + i + ".txt", batch.worlds);
// Write content to file
// TODO
// Write collections to file
// TODO
// Write sharing to file
// TODO
// Write areas to file
// TODO
// Write messages to file
// TODO
batches.push(batch);
}
};
var generateBatch = function(id){
console.log("Generating Batch " + id);
var batch = {};
batch.users = [];
for (var u = 0; u < USERS_PER_BATCH; u++){
batch.users.push(new user.User(id));
}
batch.contacts = contacts.generateContacts(batch.users);
batch.worlds = [];
for (var w = 0; w < WORLDS_PER_BATCH; w++){
batch.worlds.push(new world.World(id, batch.users));
//console.log(JSON.stringify(batch.worlds[w]));
}
batch.worlds = world.setWorldMemberships(id, batch.worlds, batch.users);
console.log("Finished Generating Batch " + id);
console.log("=================================");
return batch;
};
run();