Skip to content

Push Audiences improvements #813

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

Merged
merged 2 commits into from
Jun 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"js-beautify": "~1.6.14",
"marked": "^0.3.5",
"node-sass": "^4.5.3",
"parse": "1.9.2",
"parse": "^1.10.2",
"prismjs": "~1.6.0",
"react": "^15.0.1",
"react-addons-test-utils": "^15.0.1",
Expand Down
4 changes: 2 additions & 2 deletions src/components/PushAudienceDialog/PushAudienceDialog.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import TextInput from 'components/TextInput/TextInput.react';
import Toggle from 'components/Toggle/Toggle.react';
import { List, Map } from 'immutable';

const PARSE_SERVER_SUPPORTS_SAVED_AUDIENCES = false;
const AUDIENCE_SIZE_FETCHING_ENABLED = false;
const PARSE_SERVER_SUPPORTS_SAVED_AUDIENCES = true;
const AUDIENCE_SIZE_FETCHING_ENABLED = true;

let filterFormatter = (filters, schema) => {
return filters.map((filter) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import PushAudiencesBaseRow from 'components/PushAudiencesSelector/PushAudi

const FORM_PREFIX = 'audience_radio';

const AUDIENCE_SIZE_FETCHING_ENABLED = false;
const AUDIENCE_CREATED_DATE_ENABLED = false;
const AUDIENCE_SIZE_FETCHING_ENABLED = true;
const AUDIENCE_CREATED_DATE_ENABLED = true;

export default class PushAudiencesOption extends PushAudiencesBaseRow {
constructor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import React from 'react';
import styles from 'components/PushAudiencesSelector/PushAudiencesSelector.scss';
import { fromJS } from 'immutable';

const AUDIENCE_SIZE_FETCHING_ENABLED = false;
const AUDIENCE_CREATED_DATE_ENABLED = false;
const AUDIENCE_SIZE_FETCHING_ENABLED = true;
const AUDIENCE_CREATED_DATE_ENABLED = true;

const PushAudiencesOptions = ({
current,
Expand Down
4 changes: 3 additions & 1 deletion src/dashboard/Push/PushAudiencesData.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ export default class PushAudiencesData extends React.Component {
// Horrible code here is due to old rails code that sent pushes through it's own endpoint, while Parse Server sends through Parse.Push.
// Ideally, we would pass a Parse.Query around everywhere.
parseQuery.containedIn('deviceType', platforms);
this.props.onChange(saveForFuture ? (() => {throw "Audiences not supported"})() : PushConstants.NEW_SEGMENT_ID, parseQuery, 1 /* TODO: get the read device count */);
if (!saveForFuture) {
this.props.onChange(PushConstants.NEW_SEGMENT_ID, parseQuery, 1 /* TODO: get the read device count */);
}

if (saveForFuture){
this.props.pushAudiencesStore.dispatch(PushAudiencesStore.ActionTypes.CREATE, {
Expand Down
16 changes: 10 additions & 6 deletions src/lib/ParseApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,13 +374,17 @@ export default class ParseApp {
}

fetchPushSubscriberCount(audienceId, query) {
let path = '/apps/' + this.slug + '/dashboard_ajax/push_subscriber_count';
let urlsSeparator = '?';
if (query){
path += `?where=${encodeURI(JSON.stringify(query))}`;
urlsSeparator = '&';
let promise;
if (!query) {
promise = new Parse.Query('_Audience').get(audienceId, { useMasterKey: true }).then(function(audience) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we may wanna add caching for those counts as may be quite expensive on the DB.

Copy link
Contributor

Choose a reason for hiding this comment

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

@flovilmart do we want to add in caching with this PR or do we want to handle this later on?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also if this runs okay on your end this would be great to get in. About time we should put up a dashboard release so we can get past #811 .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, caching would need more work, not required

Copy link
Contributor

Choose a reason for hiding this comment

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

Ehhh, maybe in this case we should cache. Although we could take it as is it would be nice to not have to come back and do that later.

return Parse.Query.fromJSON('_Installation', { where: audience.get('query') }).count({ useMasterKey: true })
});
} else {
promise = Parse.Query.fromJSON('_Installation', { where: query }).count({ useMasterKey: true })
}
return AJAX.abortableGet(audienceId ? `${path}${urlsSeparator}audienceId=${audienceId}` : path);
return { xhr: undefined, promise: promise.then(function (count) {
return { count: count };
}) };
}

fetchPushNotifications(type, page, limit) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/stores/PushAudiencesStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function PushAudiencesStore(state, action) {
return Parse.Promise.as(state);
}
}
const path = action.limit ? `push_audiences?audience_limit=${action.limit}` : 'push_audiences';
const path = action.limit ? `push_audiences?limit=${action.limit}` : 'push_audiences';
const promise = Parse._request('GET', path, {}, { useMasterKey: true });

return promise.then(({ results, showMore }) => {
Expand Down