Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push overhaul #4378

Closed
wants to merge 8 commits into from
Closed

Push overhaul #4378

wants to merge 8 commits into from

Conversation

flovilmart
Copy link
Contributor

@flovilmart flovilmart commented Nov 25, 2017

Motivation:

  • we send a decent volume of push notifications and we found that the current strategy for slicing / dicing push notification is not efficient
  • I noticed in the early commits of the dashboard, that pushStatus only have 3 possible states, pending, succeeded, failed. (thus we can don't need running, which caused issues before)
  • Marking push as succeeded, when the working items have been scheduled is reasonable, perhaps, we could introduce 2 modes into the PushQueue, direct sending (calling worker directly and queue), in the case of calling the worker directly we could 'wait' till all push are sent to mark complete.
  • I also noticed, many _PushStatus types are not implemented in the dashboard, including the experiments, campaigns etc... which could be easier to implement if we start sticking to the dashboard definitions instead.
  • This will is a breaking change for anyone using a custom push worker, or scheduler, as push won't be marked as scheduled etc... anymore.
  • A scheduled push is just a pending push with a push time. This will help us move into a more scalable / modular architecture.
  • Restores the translation key support as it was originally intended on parse-dashboard

This will require to bump to 3.0.

@codecov
Copy link

codecov bot commented Nov 25, 2017

Codecov Report

Merging #4378 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4378      +/-   ##
==========================================
+ Coverage   92.77%   92.78%   +<.01%     
==========================================
  Files         119      119              
  Lines        8448     8512      +64     
==========================================
+ Hits         7838     7898      +60     
- Misses        610      614       +4
Impacted Files Coverage Δ
src/Push/PushQueue.js 100% <100%> (ø) ⬆️
src/Push/utils.js 98.59% <100%> (+0.23%) ⬆️
src/StatusHandler.js 99.25% <100%> (-0.04%) ⬇️
src/Controllers/PushController.js 97.91% <100%> (+0.02%) ⬆️
src/rest.js 98.97% <100%> (+0.19%) ⬆️
src/RestWrite.js 93.5% <0%> (-0.19%) ⬇️
...dapters/Storage/Postgres/PostgresStorageAdapter.js 96.76% <0%> (-0.11%) ⬇️
src/Routers/ClassesRouter.js 93.69% <0%> (+0.18%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7944e2b...56fd570. Read the comment docs.

@flovilmart flovilmart added this to the 3.0 milestone Nov 25, 2017
@@ -157,6 +157,138 @@ describe('PushWorker', () => {
expect(PushUtils.bodiesPerLocales({where: {}})).toEqual({default: {where: {}}});
expect(PushUtils.groupByLocaleIdentifier([])).toEqual({default: []});
});

it('should propely apply translations strings', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo on 'propely' 😛

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

meh.. look like I'm quite tired

});
});

it('should propely apply translations objects', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again here

});
});

it('should propely override alert-lang with translations', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

});
});

it('should propely override alert-lang with translations strings', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

@@ -16,6 +18,7 @@ export class PushQueue {
constructor(config: any = {}) {
this.channel = config.channel || PushQueue.defaultPushChannel();
this.batchSize = config.batchSize || DEFAULT_BATCH_SIZE;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need batchSize?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah we still need it so we have a query batch size and an enqueue batch size:

https://github.com/parse-community/parse-server/pull/4378/files#diff-6f234e6e995cfa72a42019190989aaa4R42

@@ -276,7 +408,6 @@ describe('PushWorker', () => {
'failedPerType.ios': { __op: 'Increment', amount: 1 },
[`sentPerUTCOffset.${UTCOffset}`]: { __op: 'Increment', amount: 1 },
[`failedPerUTCOffset.${UTCOffset}`]: { __op: 'Increment', amount: 1 },
count: { __op: 'Increment', amount: -1 }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're not using count on _PushStatus we should probably strip it from the schema as well, unless there's some particular need for it still.

@@ -2,9 +2,11 @@ import { ParseMessageQueue } from '../ParseMessageQueue';
import rest from '../rest';
import { applyDeviceTokenExists } from './utils';
import Parse from 'parse/node';
import logger from '../logger';

const PUSH_CHANNEL = 'parse-server-push';
const DEFAULT_BATCH_SIZE = 100;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If batchSize is not needed we can just drop this too.

Copy link
Contributor

@montymxb montymxb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some typos and questions. But the tests look good 👍 .

@@ -16,6 +18,7 @@ export class PushQueue {
constructor(config: any = {}) {
this.channel = config.channel || PushQueue.defaultPushChannel();
this.batchSize = config.batchSize || DEFAULT_BATCH_SIZE;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah we still need it so we have a query batch size and an enqueue batch size:

https://github.com/parse-community/parse-server/pull/4378/files#diff-6f234e6e995cfa72a42019190989aaa4R42

return rest.each(config, auth, '_Installation', where, options, (result) => {
total++;
currentBatch.push(result.objectId);
if (currentBatch.length == this.batchSize) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's used there.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha.

@flovilmart flovilmart closed this Aug 9, 2018
@flovilmart flovilmart deleted the push-overhaul-again branch September 25, 2018 01:27
@flovilmart flovilmart restored the push-overhaul-again branch September 25, 2018 01:27
@TomWFox TomWFox deleted the push-overhaul-again branch September 14, 2019 23:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants