Adds ability to track sent/failed PerUTCOffset in the PushWorker (#4158)

* Adds ability to track sent/failed PerUTCOffset in the PushWorker

- for scheduled push notifications at a certain time, it helps keep track of the state

* Makes sure we track it all correctly

* Adds to Postgres
This commit is contained in:
Florent Vilmart
2017-09-13 17:28:20 -04:00
committed by GitHub
parent be2760f9dd
commit d598d73f36
4 changed files with 160 additions and 22 deletions

View File

@@ -162,7 +162,7 @@ export function pushStatusHandler(config, objectId = newObjectId(config.objectId
{status: "running", updatedAt: new Date(), count });
}
const trackSent = function(results, cleanupInstallations = process.env.PARSE_SERVER_CLEANUP_INVALID_INSTALLATIONS) {
const trackSent = function(results, UTCOffset, cleanupInstallations = process.env.PARSE_SERVER_CLEANUP_INVALID_INSTALLATIONS) {
const update = {
updatedAt: new Date(),
numSent: 0,
@@ -179,6 +179,10 @@ export function pushStatusHandler(config, objectId = newObjectId(config.objectId
const deviceType = result.device.deviceType;
const key = result.transmitted ? `sentPerType.${deviceType}` : `failedPerType.${deviceType}`;
memo[key] = incrementOp(memo, key);
if (typeof UTCOffset !== 'undefined') {
const offsetKey = result.transmitted ? `sentPerUTCOffset.${UTCOffset}` : `failedPerUTCOffset.${UTCOffset}`;
memo[offsetKey] = incrementOp(memo, offsetKey);
}
if (result.transmitted) {
memo.numSent++;
} else {