-
Notifications
You must be signed in to change notification settings - Fork 12
/
createusers.js
176 lines (143 loc) · 4.54 KB
/
createusers.js
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
'use_strict'
var mongoose = require('mongoose'),
_ = require('lodash');
var Chance = require('chance');
var chance = new Chance();
var mkdirp = require('mkdirp');
var mongoose = require('mongoose');
var db = mongoose.connect('mongodb://localhost/reallove');
var guid = require('guid');
var membersModel = require('./appmodules/homepage/server/models/members').membersModel;
var registrationModule = require('./appmodules/homepage/server/models/registration');
var regSchema = registrationModule.regSchema;
var regModel = registrationModule.regModel;
var fsextera = require('fs.extra');
var user = {};
var randomGuid;
var member = {};
function copyFile(source, target) {
return new Promise(function (resolve, reject) {
var rd = fs.createReadStream(source);
rd.on('error', reject);
var wr = fs.createWriteStream(target);
wr.on('error', reject);
wr.on('finish', resolve);
rd.pipe(wr);
});
}
function createUser(nickName, gender, mail)
{
randomGuid = guid.create();
user.password = "1";
if (mail == undefined)
user.email = chance.email();
else
user.email = mail;
user.verified = true;
user.host = "http://192.168.22.32:8000";
user.userguid = randomGuid;
user.confirmPassword = true;
user.provider = "";
var userRegistration = new regModel(user);
userRegistration.save(function (err, user) {
member.registrationObjectId = user._id;
member.whoami = "s simply dummy text of the printing and typesetting industry."
member.whatdoisearch = "s simply dummy text of the printing and typesetting industry."
member.needInitiaDetailsBase = false;
member.isOnline = false;
member.needInitiaDetailsAll = false;
if (nickName == undefined) {
member.nickName = chance.string({
length: 5
});
} else {
member.nickName = nickName;
}
member.gym = "פעם בשבוע";
member.walking = "בעניין";
member.everydayathom = "כן";
member.cosher = "שומר";
member.bmi = "באזור טוב";
member.running = "בעניין";
member.jobtype = "שכיר";
member.livingwith = "בדירה לבד";
member.eatmeat = "כן";
member.moutainbikes = "רוכב";
member.cooking = "ברמה סבירה";
member.bornday = chance.integer({
min: 1,
max: 31
});;
member.bornmonth = chance.integer({
min: 1,
max: 12
});
member.bornyear = chance.integer({
min: 1930,
max: 1944
});
member.education = "דוקטור";
member.height = 185;
member.religion = "יהודי";
member.status = "רווק";
member.numberofkids = 0;
member.smoking = "לא";
member.city = "תל אביב";
member.religionbelong = "חילוני";
member.licenseandcar = 'יש לי רישיון ורכב';
member.gender = gender;
var m = new membersModel(member);
m.save(function (err, user) {
var dirToCreateRaw = './uploads/' + m.registrationObjectId + "/raw/"
console.log(dirToCreateRaw);
mkdirp(dirToCreateRaw, function (err) {
var fileName = './infra/m' + (picnum + 1) + '.jpg';
fsextera.copy(fileName, dirToCreateRaw + '1.jpg', {
replace: false
},
function (err) {
if (err) {
console.log("error copy file:" + err);
} else {
console.log('Copied ok');
}
});
fsextera.copy(fileName, dirToCreateRaw + '0.jpg', {
replace: false
},
function (err) {
if (err) {
console.log("error copy file:" + err);
} else {
console.log('Copied ok');
}
});
fsextera.copy(fileName, dirToCreateRaw + '100.jpg', {
replace: false
},
function (err) {
if (err) {
console.log("error copy file:" + err);
} else {
console.log('Copied ok');
}
});
picnum = (picnum + 1) % 8;
});
});
console.log("creating.. " + user.email);
});
}
var picnum = 1;
var g = ['אישה', 'גבר'];
for (var i = 0; i < 20; i++) {
createUser(undefined , g[1], undefined);
}
//createUser('amit' , g[1], '[email protected]');
//createUser('nataly' , g[1], '[email protected]');
//createUser('noam' , g[1], '[email protected]');
//createUser('amir' , g[1], '[email protected]');
//createUser('shamay' , g[1], '[email protected]');
process.stdin.setRawMode(true);
process.stdin.resume();
process.stdin.on('data', process.exit.bind(process, 0));