Lets increment/set badges on all _Installations (#3970)
* Lets increment/set badges on all _Installations * Makes sure PG update where query is properly formed with empty query
This commit is contained in:
@@ -172,12 +172,8 @@ describe('PushController', () => {
|
|||||||
send: function(body, installations) {
|
send: function(body, installations) {
|
||||||
var badge = body.data.badge;
|
var badge = body.data.badge;
|
||||||
installations.forEach((installation) => {
|
installations.forEach((installation) => {
|
||||||
if (installation.deviceType == "ios") {
|
expect(installation.badge).toEqual(badge);
|
||||||
expect(installation.badge).toEqual(badge);
|
expect(installation.originalBadge + 1).toEqual(installation.badge);
|
||||||
expect(installation.originalBadge + 1).toEqual(installation.badge);
|
|
||||||
} else {
|
|
||||||
expect(installation.badge).toBeUndefined();
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
return successfulTransmissions(body, installations);
|
return successfulTransmissions(body, installations);
|
||||||
},
|
},
|
||||||
@@ -203,7 +199,9 @@ describe('PushController', () => {
|
|||||||
while(installations.length != 15) {
|
while(installations.length != 15) {
|
||||||
const installation = new Parse.Object("_Installation");
|
const installation = new Parse.Object("_Installation");
|
||||||
installation.set("installationId", "installation_" + installations.length);
|
installation.set("installationId", "installation_" + installations.length);
|
||||||
installation.set("deviceToken","device_token_" + installations.length)
|
installation.set("deviceToken","device_token_" + installations.length);
|
||||||
|
installation.set("badge", installations.length);
|
||||||
|
installation.set("originalBadge", installations.length);
|
||||||
installation.set("deviceType", "android");
|
installation.set("deviceType", "android");
|
||||||
installations.push(installation);
|
installations.push(installation);
|
||||||
}
|
}
|
||||||
@@ -238,12 +236,7 @@ describe('PushController', () => {
|
|||||||
expect(results.length).toBe(15);
|
expect(results.length).toBe(15);
|
||||||
for (var i = 0; i < 15; i++) {
|
for (var i = 0; i < 15; i++) {
|
||||||
const installation = results[i];
|
const installation = results[i];
|
||||||
if (installation.get('deviceType') == 'ios') {
|
expect(installation.get('badge')).toBe(parseInt(installation.get('originalBadge')) + 1);
|
||||||
expect(installation.get('badge')).toBe(parseInt(installation.get('originalBadge')) + 1);
|
|
||||||
} else {
|
|
||||||
expect(installation.get('badge')).toBe(undefined);
|
|
||||||
expect(installation.get('originalBadge')).toBe(undefined);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
done()
|
done()
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
|
|||||||
@@ -1091,7 +1091,8 @@ export class PostgresStorageAdapter {
|
|||||||
const where = buildWhereClause({ schema, index, query })
|
const where = buildWhereClause({ schema, index, query })
|
||||||
values.push(...where.values);
|
values.push(...where.values);
|
||||||
|
|
||||||
const qs = `UPDATE $1:name SET ${updatePatterns.join(',')} WHERE ${where.pattern} RETURNING *`;
|
const whereClause = where.pattern.length > 0 ? `WHERE ${where.pattern}` : '';
|
||||||
|
const qs = `UPDATE $1:name SET ${updatePatterns.join(',')} ${whereClause} RETURNING *`;
|
||||||
debug('update: ', qs, values);
|
debug('update: ', qs, values);
|
||||||
return this._client.any(qs, values);
|
return this._client.any(qs, values);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ export class PushController {
|
|||||||
const updateWhere = deepcopy(where);
|
const updateWhere = deepcopy(where);
|
||||||
|
|
||||||
badgeUpdate = () => {
|
badgeUpdate = () => {
|
||||||
updateWhere.deviceType = 'ios';
|
|
||||||
// Build a real RestQuery so we can use it in RestWrite
|
// Build a real RestQuery so we can use it in RestWrite
|
||||||
const restQuery = new RestQuery(config, master(config), '_Installation', updateWhere);
|
const restQuery = new RestQuery(config, master(config), '_Installation', updateWhere);
|
||||||
return restQuery.buildRestWhere().then(() => {
|
return restQuery.buildRestWhere().then(() => {
|
||||||
|
|||||||
@@ -14,10 +14,7 @@ const UNSUPPORTED_BADGE_KEY = "unsupported";
|
|||||||
|
|
||||||
function groupByBadge(installations) {
|
function groupByBadge(installations) {
|
||||||
return installations.reduce((map, installation) => {
|
return installations.reduce((map, installation) => {
|
||||||
let badge = installation.badge + '';
|
const badge = installation.badge + '';
|
||||||
if (installation.deviceType != "ios") {
|
|
||||||
badge = UNSUPPORTED_BADGE_KEY;
|
|
||||||
}
|
|
||||||
map[badge] = map[badge] || [];
|
map[badge] = map[badge] || [];
|
||||||
map[badge].push(installation);
|
map[badge].push(installation);
|
||||||
return map;
|
return map;
|
||||||
|
|||||||
Reference in New Issue
Block a user