Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Q #12

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Q #12

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions data/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"debug": true,
"name": "Keeling Js Default",
"port": 21023,
"allow_cross_origin": false,
"session_secret": "keeling-session",
"engine": "ejs",
"default_page": "index",
"error_page": "error",
"public_directory": "public",
"ajax_directory": "ajax",
"router_directory": "router",
"schedule_directory": "schedule"
}
44 changes: 44 additions & 0 deletions data/mock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
var MongoClient = require('mongodb').MongoClient;
var fs = require('fs');
var username = 'admin'
var password = 'DE54mdvb5p9swfi9'
var conn_str = "mongodb://admin:[email protected]:27017,test-shard-00-01-cgxsm.mongodb.net:27017,test-shard-00-02-cgxsm.mongodb.net:27017/test?ssl=true&replicaSet=test-shard-0&authSource=admin"
MongoClient.connect(conn_str, function(err, db){
if(err){
console.log("Please check you db connection parameters");
}else{
console.log("Connection success");
var user_file = 'mock_user';
var leasing_file = 'mock_leasing';
var complex_file = 'mock_complex';
var user_list = JSON.parse(fs.readFileSync(user_file).toString('utf-8'));
var leasing_list = JSON.parse(fs.readFileSync(leasing_file).toString('utf-8'));
var complex_list = JSON.parse(fs.readFileSync(complex_file).toString('utf-8'));
db = db.db("cssa")
console.log("Current database", db.databaseName);

var collection = db.collection('user');
collection.remove({})
for (var i = 0; i < user_list.length; i++){
var user = user_list[i];
collection.insert(user)
}

var collection = db.collection('leasing');
collection.remove({})
for (var i = 0; i < leasing_list.length; i++){
var leasing = leasing_list[i];
collection.insert(leasing)
}

var collection = db.collection('complex');
// collection.remove({})
for (var i = 0; i < complex_list.length; i++){
var complex = complex_list[i];
if(complex.length == 6)
collection.insert(complex)
}

db.close()
}
});
5 changes: 5 additions & 0 deletions data/mock_complex
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[{



}]
195 changes: 195 additions & 0 deletions data/mock_leasing
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
[{
"user_id": "CSE30",
"start_date": "2019-01-31",
"end_date": "2019-02-28",
"complex_id": "5c4b9c9cfbe228dca44f5856",
"apt_bedroom_amount": 3,
"apt_bathroom_amount": 2,
"room_avail":[
{
"type": "living",
"price": 1350
}, {
"type": "bedroom",
"price": 2000
}
],
"gender_req": 2,
"user_description": "I love CrazyOrbs!",
"facility":{
"wifi":true,
"pet":true,
"washer":true,
"furniture":false,
"printer":false,
"ac":false,
"heater":true,
"parking":true,
"kitchen":true
},
"notice": "Where are my Math-CS majors?",
"location":{
"lng": "32.870180",
"lat": "-117.216793"
},
"status": 0,
"img_url": [
"cse30.ucsd.edu",
"cse11.ucsd.edu"
]
},{
"user_id": "CSE21",
"start_date": "2019-01-31",
"end_date": "2019-02-28",
"complex_id": "5c4b9c9cfbe228dca44f5856",
"apt_bedroom_amount": 2,
"apt_bathroom_amount": 2,
"room_avail":[
{
"type": "living",
"price": 350
}, {
"type": "bedroom",
"price": 400
}
],
"gender_req": 2,
"user_description": "MJMJMJMJ",
"facility":{
"wifi":true,
"pet":true,
"washer":true,
"furniture":false,
"printer":false,
"ac":false,
"heater":true,
"parking":true,
"kitchen":true
},
"notice": "I used the large living room to tutor my students",
"location":{
"lng": "32.870180",
"lat": "-117.216793"
},
"status": 0,
"img_url": [
"cse21.ucsd.edu",
"cse101.ucsd.edu",
"cse105.ucsd.edu"
]
},{
"user_id": "Mamahaha",
"start_date": "2019-03-31",
"end_date": "2019-04-30",
"complex_id": "5c4b9c9cfbe228dca44f5856",
"apt_bedroom_amount": 3,
"apt_bathroom_amount": 2,
"room_avail":[
{
"type": "living",
"price": 900
}, {
"type": "bedroom",
"price": 1400
}
],
"gender_req": 2,
"user_description": "great room for playing video game",
"facility":{
"wifi":true,
"pet":false,
"washer":true,
"furniture":true,
"printer":true,
"ac":false,
"heater":true,
"parking":true,
"kitchen":true
},
"notice": "If you want to study, then I won't rent you the room",
"location":{
"lng": "32.870180",
"lat": "-117.216793"
},
"status": 0,
"img_url": [
"games.qq.com"
]
},{
"user_id": "Gina",
"start_date": "2019-02-14",
"end_date": "2019-02-19",
"complex_id": "5c4b9c9cfbe228dca44f5856",
"apt_bedroom_amount": 3,
"apt_bathroom_amount": 2,
"room_avail":[
{
"type": "living",
"price": 1
}, {
"type": "bedroom",
"price": 1
}
],
"gender_req": 0,
"user_description": "Free to come and spend the Valentine's day with me :(",
"facility":{
"wifi":true,
"pet":false,
"washer":true,
"furniture":true,
"printer":true,
"ac":false,
"heater":true,
"parking":true,
"kitchen":true
},
"notice": "怎么了小老弟",
"location":{
"lng": "32.870180",
"lat": "-117.216793"
},
"status": 0,
"img_url": [
"singleforever.ucsd.edu"
]
},{
"user_id": "Charles",
"start_date": "2019-05-14",
"end_date": "2019-06-13",
"complex_id": "5c4b9c9cfbe228dca44f5856",
"apt_bedroom_amount": 3,
"apt_bathroom_amount": 2,
"room_avail":[
{
"type": "living",
"price":750
}, {
"type": "bedroom",
"price": 1200
}
],
"gender_req": 2,
"user_description": "我要去环游世界了,嘤嘤嘤",
"facility":{
"wifi":true,
"pet":false,
"washer":true,
"furniture":true,
"printer":true,
"ac":false,
"heater":true,
"parking":true,
"kitchen":true
},
"notice": "你要敢把我家具弄坏看我不****",
"location":{
"lng": "32.870180",
"lat": "-117.216793"
},
"status": 0,
"img_url": [
"www.charlesroom.com/bedroom",
"www.charlesroom.com/livingroom"
]
}]
66 changes: 66 additions & 0 deletions data/mock_user
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
[{
"username": "QQDL",
"email": "[email protected]",
"real_name": "张恩齐",
"qr_code": "data:image/png;base64,encoding"
},{
"username": "Tina",
"email": "[email protected]",
"real_name": "谭鑫培",
"qr_code": "data:image/png;base64,encoding"
},{
"username": "Charles",
"email": "[email protected]",
"real_name": "欧阳秀儿",
"qr_code": "data:image/png;base64,encoding"
},{
"username": "Mamahaha",
"email": "[email protected]",
"real_name": "娜可露露",
"qr_code": "data:image/png;base64,encoding"
},{
"username": "User1",
"email": "[email protected]",
"real_name": "用户1",
"qr_code": "data:image/png;base64,encoding"
},{
"username": "Food insecurity",
"email": "[email protected]",
"real_name": "写作",
"qr_code": "data:image/png;base64,encoding"
},{
"username": "GMO",
"email": "[email protected]",
"real_name": "Genetically Modified Organism",
"qr_code": "data:image/png;base64,encoding"
},{
"username": "Professionalism",
"email": "[email protected]",
"real_name": "Gary",
"qr_code": "data:image/png;base64,encoding"
},{
"username": "CSE30",
"email": "[email protected]",
"real_name": "Rick Ord",
"qr_code": "data:image/png;base64,encoding"
},{
"username": "Richman",
"email": "[email protected]",
"real_name": "Miles Jones",
"qr_code": "data:image/png;base64,encoding"
},{
"username": "匿名用户1",
"email": "[email protected]",
"real_name": "Unknown",
"qr_code": "data:image/png;base64,encoding"
},{
"username": "匿名用户2",
"email": "[email protected]",
"real_name": "Unknown",
"qr_code": "data:image/png;base64,encoding"
},{
"username": "匿名用户3",
"email": "[email protected]",
"real_name": "Unknown",
"qr_code": "data:image/png;base64,encoding"
}]
33 changes: 33 additions & 0 deletions data/mockdata.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
var MongoClient = require('mongodb').MongoClient;
var username = 'admin'
var password = 'DE54mdvb5p9swfi9'
var host = 'test-shard-00-01-cgxsm.mongodb.net:27017'
MongoClient.connect('mongodb://'+username+':'+password+host, function(err, db){
if(err){
console.log("Please check you db connection parameters");
}else{
console.log("Connection success");
// here we are going to write code for file
}
});
var fs = require('fs');

// db = db.getSiblingDB('cssa');
// db.user.remove({})
var filename = 'user.txt';
// var str = JSON.stringify(userList, null, 4);

// fs.writeFile(filename, str, function(err){
// if(err) {
// console.log(err)
// } else {
// console.log('File written!');
// }
// });

var userList = JSON.parse(fs.readFileSync(filename).toString('utf-8'));

for (var i = 0; i < userList.length; i++){
var user = userList[i];
db.user.insert({username: user.username, email: user.email, real_name: user.real_name, qr_code: user.qr_code})
}
Loading