mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 15:48:11 -05:00
🐛Fix analytics revenue payment.created
This commit is contained in:
parent
e56efe5921
commit
d9a52c62f1
1 changed files with 22 additions and 28 deletions
|
@ -7,39 +7,33 @@
|
|||
|
||||
// TODO: Investigate school sales amount == zero. Manual input error?
|
||||
|
||||
try {
|
||||
var scriptStartTime = new Date();
|
||||
var analyticsStringCache = {};
|
||||
var scriptStartTime = new Date();
|
||||
var analyticsStringCache = {};
|
||||
|
||||
var numDays = 40;
|
||||
var daysInMonth = 30;
|
||||
var numDays = 40;
|
||||
var daysInMonth = 30;
|
||||
|
||||
var startDay = new Date();
|
||||
today = startDay.toISOString().substr(0, 10);
|
||||
startDay.setUTCDate(startDay.getUTCDate() - numDays);
|
||||
startDay = startDay.toISOString().substr(0, 10);
|
||||
var startDay = new Date();
|
||||
today = startDay.toISOString().substr(0, 10);
|
||||
startDay.setUTCDate(startDay.getUTCDate() - numDays);
|
||||
startDay = startDay.toISOString().substr(0, 10);
|
||||
|
||||
log("Today is " + today);
|
||||
log("Start day is " + startDay);
|
||||
log("Today is " + today);
|
||||
log("Start day is " + startDay);
|
||||
|
||||
log("Getting recurring revenue counts...");
|
||||
var recurringRevenueCounts = getRecurringRevenueCounts(startDay);
|
||||
// printjson(recurringRevenueCounts);
|
||||
log("Inserting recurring revenue counts...");
|
||||
for (var event in recurringRevenueCounts) {
|
||||
for (var day in recurringRevenueCounts[event]) {
|
||||
if (today === day) continue; // Never save data for today because it's incomplete
|
||||
// print(event, day, recurringRevenueCounts[event][day]);
|
||||
insertEventCount(event, day, recurringRevenueCounts[event][day]);
|
||||
}
|
||||
log("Getting recurring revenue counts...");
|
||||
var recurringRevenueCounts = getRecurringRevenueCounts(startDay);
|
||||
// printjson(recurringRevenueCounts);
|
||||
log("Inserting recurring revenue counts...");
|
||||
for (var event in recurringRevenueCounts) {
|
||||
for (var day in recurringRevenueCounts[event]) {
|
||||
if (today === day) continue; // Never save data for today because it's incomplete
|
||||
// print(event, day, recurringRevenueCounts[event][day]);
|
||||
insertEventCount(event, day, recurringRevenueCounts[event][day]);
|
||||
}
|
||||
}
|
||||
|
||||
log("Script runtime: " + (new Date() - scriptStartTime));
|
||||
}
|
||||
catch(err) {
|
||||
log("ERROR: " + err);
|
||||
printjson(err);
|
||||
}
|
||||
log("Script runtime: " + (new Date() - scriptStartTime));
|
||||
|
||||
function getRecurringRevenueCounts(startDay) {
|
||||
if (!startDay) return {};
|
||||
|
@ -53,7 +47,7 @@ function getRecurringRevenueCounts(startDay) {
|
|||
while (cursor.hasNext()) {
|
||||
var doc = cursor.next();
|
||||
if (doc.created) {
|
||||
day = doc.created.substring(0, 10);
|
||||
day = new Date(doc.created).toISOString().substring(0, 10);
|
||||
}
|
||||
else {
|
||||
day = doc._id.getTimestamp().toISOString().substring(0, 10);
|
||||
|
|
Loading…
Reference in a new issue