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

MLIBZ-2131 Remove implicit push() calls #276

Merged
merged 7 commits into from
Mar 29, 2018
Merged

MLIBZ-2131 Remove implicit push() calls #276

merged 7 commits into from
Mar 29, 2018

Conversation

gprodanov
Copy link
Contributor

Description

Remove the implicit push() calls in DataStore.pull(), CacheStore.find(), CacheStore.findById(), CacheStore.count(), CacheStore.group(). This removes potentially unexpected behaviour and improves the number of local reads from 2 to 4, to always 2.

Changes

Remove the count-push-count flow from CacheStore read-based ops. They do count and return an error if there are entities pending push. Otherwise proceed with their regular flow.

Put the check for entities pending push after the return of the offline result - it isn't being impeded by the entities pending sync.

Update tests accordingly.

Change the error message - input welcome.

import { isNonemptyString } from '../../utils';

export const dataStoreTagSeparator = '.';

export function getEntitiesPendingPushError(entityCount, prefix) {
const countMsg = `There are ${entityCount} entities, matching this query or id, pending push to the backend.`;
Copy link
Contributor

Choose a reason for hiding this comment

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

Lets use an if statement to make the count message more grammatically correct.

let countMsg = `There are ${entityCount} entities, matching the provided query, pending push to the backend.`;

if (entityCount === 1) {
  countMsg = `There is ${entitiyCount} entity, matching the provided query or id, pending push to the backend.`;
}

import { isNonemptyString } from '../../utils';

export const dataStoreTagSeparator = '.';

export function getEntitiesPendingPushError(entityCount, prefix) {
const countMsg = `There are ${entityCount} entities, matching this query or id, pending push to the backend.`;
const errMsg = `Unable to ${prefix} on the backend, since the result might overwrite your local changes. ${countMsg}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

I would suggest to break up the error message into two sentences.

const errMsg = `Unable to ${prefix} on the backend. The result might overwrite your local changes.`;

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a little confused. When does errMsg get used?
I think the revised version from Thomas is an improvement, but I'd like to avoid the phrase "might overwrite" if possible. Can we say something more concrete?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

errMsg is the entire message - it's always used. Just there were a few, slightly different, error messages (thus "prefix" parameter).

The method exists just to build the error message. As we discussed, there will someday be a general error factory, but until then, this will have to suffice.

I guess "the returned entities would overwrite your local entities" is more concrete. How about it?

Copy link
Contributor

Choose a reason for hiding this comment

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

The result will overwrite your local changes. @tejasranade thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

Cool, I think will or can sounds more concrete. @thomasconner let's go with yours.

…Store. Remove outdated tests, change error message for when entities are pending push. Change tests to feature the new message.
…re.count(), that returned an error when there are entities to push. Change tests accordingly.
thomasconner
thomasconner previously approved these changes Mar 29, 2018
Copy link
Contributor

@tejasranade tejasranade left a comment

Choose a reason for hiding this comment

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

LGTM

@thomasconner thomasconner merged commit a0b105a into master Mar 29, 2018
@thomasconner thomasconner deleted the minimize-gets branch March 29, 2018 15:08
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