-
Notifications
You must be signed in to change notification settings - Fork 12
Update Statistics To Realtime w/ Caching #194
base: staging
Are you sure you want to change the base?
Conversation
ASankaran
commented
Jan 29, 2018
•
edited
Loading
edited
- Write registration, rsvp, and live stats to database and cache in realtime
- Read stats back from cache when possible
- Read stats from db and write to cache when needed
- Remove outdated stats (ie. tracks)
- Update docs
Slightly updated response format:
|
Mail List fix
What's the status on this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also are there no changes to the stats controller/service?
api/v1/controllers/RSVPController.js
Outdated
@@ -4,7 +4,7 @@ const services = require('../services'); | |||
const middleware = require('../middleware'); | |||
const requests = require('../requests'); | |||
const roles = require('../utils/roles'); | |||
const mail = require('../utils/mail'); | |||
const config = require('../../config'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ctx
api/v1/models/Stat.js
Outdated
const Model = require('./Model'); | ||
const validators = require('../utils/validators'); | ||
|
||
const CATEGORIES = ['registration', 'rsvp', 'liveevent']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
live_event
api/v1/models/Stat.js
Outdated
category: category, | ||
stat: stat, | ||
field: field | ||
}).query().count().then((count) => _Promise.resolve(count[0]['count(*)'] > 0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you do .where().count()
api/v1/models/Stat.js
Outdated
amount = 1; | ||
} | ||
|
||
const s = Stat.query((qb) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return Stat.where().fetch().increment()
@@ -17,4 +17,10 @@ TrackingEvent.findByName = function(searchName) { | |||
.fetch(); | |||
}; | |||
|
|||
TrackingEvent.findAll = function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe this is necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stats Service needs it to query all the tracked events and report the number of people who checked in.
api/v1/services/CheckInService.js
Outdated
@@ -61,6 +62,8 @@ module.exports.createCheckIn = (attributes) => { | |||
const credentialsRequested = attributes.credentialsRequested; | |||
delete attributes.credentialsRequested; | |||
|
|||
StatsService.incrementStat('liveevent', 'attendees', 'count'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
live_event
api/v1/services/RSVPService.js
Outdated
@@ -22,6 +25,18 @@ module.exports.getRSVPById = (id) => RSVP.findById(id); | |||
* @throws {InvalidParameterError} thrown when an attendee already has an rsvp | |||
*/ | |||
module.exports.createRSVP = (attendee, user, attributes) => { | |||
|
|||
StatsService.incrementStat('rsvp', 'school', attendee.get('school')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
preferably the controller has a const array which designates which fields to increment and then you can call the stat update function for-each element of the array
api/v1/services/TrackingService.js
Outdated
@@ -66,6 +69,8 @@ module.exports.addEventParticipant = (participantId) => { | |||
|
|||
currentEvent = result; | |||
|
|||
StatsService.incrementStat('liveevent', 'events', currentEvent); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
live_event
|
||
INSERT INTO `stats` (`category`, `stat`, `field`) VALUES ('liveevent', 'attendees', 'count'); | ||
|
||
#INSERT INTO `stats` (`category`, `stat`, `field`) VALUES ('liveevent', `status`, `ACCEPTED`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cleaning up this sql table would be nice