From e79cadc76158636cfe93d41f270abaa97dbf4a7b Mon Sep 17 00:00:00 2001 From: Matt Lott Date: Wed, 14 Jan 2015 13:03:02 -0800 Subject: [PATCH] Remove analytics.log.event created field _id field already has created data: http://docs.mongodb.org/manual/reference/object-id/ Also some misc analytics cleanup. --- app/schemas/models/analytics_log_event.coffee | 1 - app/schemas/models/analytics_perday.coffee | 1 + server/analytics/AnalyticsLogEvent.coffee | 8 ++------ server/analytics/AnalyticsPerDay.coffee | 1 + server/analytics/analytics_log_event_handler.coffee | 5 +++-- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/app/schemas/models/analytics_log_event.coffee b/app/schemas/models/analytics_log_event.coffee index 60705cd50..1468d0ecc 100644 --- a/app/schemas/models/analytics_log_event.coffee +++ b/app/schemas/models/analytics_log_event.coffee @@ -6,7 +6,6 @@ AnalyticsLogEventSchema = c.object { } _.extend AnalyticsLogEventSchema.properties, - created: c.date({title: 'Created', readOnly: true}) user: c.objectId(links: [{rel: 'extra', href: '/db/user/{($)}'}]) event: {type: 'string'} properties: {type: 'object'} diff --git a/app/schemas/models/analytics_perday.coffee b/app/schemas/models/analytics_perday.coffee index a41126beb..77528dc27 100644 --- a/app/schemas/models/analytics_perday.coffee +++ b/app/schemas/models/analytics_perday.coffee @@ -7,6 +7,7 @@ AnalyticsPerDaySchema = c.object { _.extend AnalyticsPerDaySchema.properties, d: {type: 'string'} # yyyymmdd day, e.g. '20150123' + e: {type: 'integer'} # event (analytics string ID from analytics.strings) l: {type: 'integer'} # level (analytics ID from analytics.strings) f: {type: 'integer'} # filter (analytics ID from analytics.strings) fv: {type: 'integer'} # filter value (analytics ID from analytics.strings) diff --git a/server/analytics/AnalyticsLogEvent.coffee b/server/analytics/AnalyticsLogEvent.coffee index 1f82c2780..62364016e 100644 --- a/server/analytics/AnalyticsLogEvent.coffee +++ b/server/analytics/AnalyticsLogEvent.coffee @@ -1,11 +1,7 @@ mongoose = require 'mongoose' plugins = require '../plugins/plugins' -AnalyticsLogEventSchema = new mongoose.Schema({ - created: - type: Date - 'default': Date.now -}, {strict: false}) -AnalyticsLogEventSchema.index({event: 1, created: -1}) +AnalyticsLogEventSchema = new mongoose.Schema({}, {strict: false}) +AnalyticsLogEventSchema.index({event: 1, _id: 1}) module.exports = AnalyticsLogEvent = mongoose.model('analytics.log.event', AnalyticsLogEventSchema) diff --git a/server/analytics/AnalyticsPerDay.coffee b/server/analytics/AnalyticsPerDay.coffee index bcc32239b..bcd726f06 100644 --- a/server/analytics/AnalyticsPerDay.coffee +++ b/server/analytics/AnalyticsPerDay.coffee @@ -1,6 +1,7 @@ mongoose = require 'mongoose' AnalyticsPerDaySchema = new mongoose.Schema({ + d: {type: String} # yyyymmdd day, e.g. '20150123' e: {type: Number} # event (analytics string ID from analytics.strings) l: {type: Number} # level (analytics string ID from analytics.strings) f: {type: Number} # filter (analytics string ID from analytics.strings) diff --git a/server/analytics/analytics_log_event_handler.coffee b/server/analytics/analytics_log_event_handler.coffee index 7d2f048a4..1ef08a8fc 100644 --- a/server/analytics/analytics_log_event_handler.coffee +++ b/server/analytics/analytics_log_event_handler.coffee @@ -22,8 +22,9 @@ class AnalyticsLogEventHandler extends Handler instance getByRelationship: (req, res, args...) -> - return @getLevelCompletionsBySlug(req, res) if args[1] is 'level_completions' - return @getCampaignCompletionsBySlug(req, res) if args[1] is 'campaign_completions' + # TODO: Remove these APIs + # return @getLevelCompletionsBySlug(req, res) if args[1] is 'level_completions' + # return @getCampaignCompletionsBySlug(req, res) if args[1] is 'campaign_completions' super(arguments...) getLevelCompletionsBySlug: (req, res) ->