codecombat/server/analytics/analytics_stripe_invoice_handler.coffee
Matt Lott 0768b533e2 Subs dashboard perf
Caching older (at least 16 days) Stripe invoices in analytics
collection, which will be updated once a day via the analytics server
cron job.
2015-07-31 16:19:40 -07:00

20 lines
692 B
CoffeeScript

Handler = require '../commons/Handler'
AnalyticsStripeInvoice = require './AnalyticsStripeInvoice'
class AnalyticsStripeInvoiceHandler extends Handler
modelClass: AnalyticsStripeInvoice
jsonSchema: require '../../app/schemas/models/analytics_stripe_invoice'
hasAccess: (req) -> req.user?.isAdmin()
getByRelationship: (req, res, args...) ->
return @sendForbiddenError(res) unless @hasAccess(req)
return @getAll(req, res) if args[1] is 'all'
super(arguments...)
getAll: (req, res) ->
AnalyticsStripeInvoice.find {}, (err, docs) =>
return @sendDatabaseError(res, err) if err
@sendSuccess(res, docs)
module.exports = new AnalyticsStripeInvoiceHandler()