Conversation
Signed-off-by: Gaurav <gogarattan@gmail.com>
| let startTime = req.body.startTime; | ||
| let endTime = req.body.endTime; | ||
| let eventDescription = req.body.eventDescription; | ||
|
|
There was a problem hiding this comment.
Make generic body design of event data. Many new fields can be introduced later on. So accept form data as json and parse it here.
| endTime : endTime | ||
| }) | ||
| .then((snapshot) => { | ||
| console.log('done') |
There was a problem hiding this comment.
Modify the success message to "Added {event} to timeline successfully".
| console.log('done') | ||
| }).catch((err) => { | ||
| res.send(err) | ||
| }) |
There was a problem hiding this comment.
Appropriate error statement: Error occurred while adding to timeline
| eventDescription : eventDescription, | ||
| startTime : startTime, | ||
| endTime : endTime | ||
| }).then((snapshot) => { |
There was a problem hiding this comment.
Change to generic implementation
| }).catch((err) => { | ||
| return res.send(err) | ||
| }) | ||
| }) |
|
|
||
| const db = admin.database().ref(); | ||
|
|
||
| exports.addEvent = functions.https.onRequest((req,res) => { |
There was a problem hiding this comment.
No comments? Please explain this function in comments
| { | ||
| var obj = {}; | ||
| obj.name = i; | ||
| data.categories.push(obj); |
There was a problem hiding this comment.
Response should be like :
{
"categories": ["a", "b"]
}
| { | ||
| var obj = {}; | ||
| obj.category = category, | ||
| obj.name = database[category][event].name; |
There was a problem hiding this comment.
Change this as previous: {
"managerial": ["a", "b"],
"programming" : ["a","b"]
}
| } | ||
| else if(req.query.category == 'one') | ||
| { | ||
| let cat = req.query.eventCategory; |
| }) | ||
| } | ||
| else { | ||
| return res.send("Invalid parameters."); |
|
|
||
| exports.getEventDescription = functions.https.onRequest((req,res) => { | ||
|
|
||
| if(req.query.events == 'all') |
There was a problem hiding this comment.
Remove this. Dead code. Never all events are required. Use cases are:
- Single event
- All events for one category.
|
|
||
| exports.getCategories = functions.https.onRequest((req,res) => { | ||
|
|
||
| return db.child('events').once('value') |
There was a problem hiding this comment.
Do not hard-code these strings. Declare global variables for references.
There was a problem hiding this comment.
no need to declare them global . this is the general uniform format of writing code .
|
|
||
| if(req.query.category == 'all') | ||
| { | ||
| return db.child('events').once('value') |
There was a problem hiding this comment.
Do not hard-code these strings. Declare global variables for references.
| else if(req.query.category == 'one') | ||
| { | ||
| let cat = req.query.eventCategory; | ||
| return db.child(`events/${cat}`).once('value') |
There was a problem hiding this comment.
Do not hard-code these strings. Declare global variables for references.
|
|
||
| if(req.query.events == 'all') | ||
| { | ||
| return db.child('eventDescription').once('value') |
There was a problem hiding this comment.
Do not hard-code these strings. Declare global variables for references.
|
|
||
| var events=database[category]; | ||
|
|
||
| for(var event in events) |
There was a problem hiding this comment.
build separate function for this
| data.eventDesciption.push(obj); | ||
| } | ||
| } | ||
| return res.send(data); |
| let eventName = req.query.eventName | ||
|
|
||
| if(eventCategory == null || eventName == null) { | ||
| res.send("Insufficient parameters.") |
There was a problem hiding this comment.
Print event category and event name values
| db.child(`eventDescription/${eventCategory}/${eventName}`).once('value') | ||
| .then((snapshot) => { | ||
| if(snapshot == null) { | ||
| return res.send("Event Doesn't Exist."); |
| return res.send(err) | ||
| }) | ||
| } | ||
| else if(req.query.events == 'cat') |
| let categoryName = req.query.eventCategory; | ||
| if(categoryName == null) | ||
| { | ||
| return res.send("Insufficient Parameters."); |
functions/index.js
Outdated
| response.send("Invalid Parameters."); | ||
| } | ||
|
|
||
| const request = require('request'); |
functions/index.js
Outdated
| { | ||
| return console.log(err); | ||
| } | ||
| console.log(body); |
There was a problem hiding this comment.
Do we need to log complete body?
functions/index.js
Outdated
| } | ||
|
|
||
| let email1 = body.emails[0].value; | ||
| let email = email1.replace(/\./g,','); |
There was a problem hiding this comment.
Make seperate function for this and rename this variable.
functions/index.js
Outdated
| let node = "userRegistrations/"+ eventName; | ||
| console.log(node); | ||
| // let db = database.ref(); | ||
| let db = admin.database().ref(); |
functions/index.js
Outdated
|
|
||
| db.child(`${node}`).push(email); | ||
|
|
||
| db.child("users/" + email + "/events").once('value') |
functions/index.js
Outdated
| } | ||
| else | ||
| { | ||
| newEventString = eventString + ", " + eventName; |
functions/index.js
Outdated
| "events": newEventString | ||
| }) | ||
| .then(() => { | ||
| response.send("Registered"); |
functions/index.js
Outdated
| }) | ||
| .catch((error) => { | ||
| console.log(error); | ||
| response.send("Could not Register!"); |
Signed-off-by: Gaurav gogarattan@gmail.com
Signed-off-by: Ankur Charan ankurcharan98@gmail.com
Signed-off-by: Vaibhav
Signed-off-by: Harshita