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

Conversation

@georgiwe
Copy link
Contributor

commented Mar 23, 2018

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.

@georgiwe georgiwe requested review from thomasconner and tejasranade Mar 23, 2018

@georgiwe georgiwe force-pushed the minimize-gets branch from 3239322 to 27135dc Mar 23, 2018

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.`;

This comment has been minimized.

Copy link
@thomasconner

thomasconner Mar 23, 2018

Contributor

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}`;

This comment has been minimized.

Copy link
@thomasconner

thomasconner Mar 23, 2018

Contributor

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.`;

This comment has been minimized.

Copy link
@tejasranade

tejasranade Mar 23, 2018

Member

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?

This comment has been minimized.

Copy link
@georgiwe

georgiwe Mar 23, 2018

Author Contributor

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?

This comment has been minimized.

Copy link
@thomasconner

thomasconner Mar 26, 2018

Contributor

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

This comment has been minimized.

Copy link
@tejasranade

tejasranade Mar 28, 2018

Member

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

georgiwe added 4 commits Mar 23, 2018
MLIBZ-2131 Remove implicit push() from GET-based operations for Cache…
…Store. Remove outdated tests, change error message for when entities are pending push. Change tests to feature the new message.
MLIBZ-2131 Remove the restriction for CacheStore.group() and CacheSto…
…re.count(), that returned an error when there are entities to push. Change tests accordingly.

@georgiwe georgiwe force-pushed the minimize-gets branch from 27135dc to 26f9e86 Mar 23, 2018

@tejasranade
Copy link
Member

left a comment

LGTM

@thomasconner thomasconner merged commit a0b105a into master Mar 29, 2018

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@thomasconner thomasconner deleted the minimize-gets branch Mar 29, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.