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

added fix to allow increase no. of reference fields without reseting counter #53

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

bhanuc
Copy link

@bhanuc bhanuc commented Mar 7, 2019

This PR allows a user to increase his scope fields without resetting his counter.
For example if we have reference fields -> ["city", "district"] and for some reason, we want reference fields -> ["city", "district", "country"], currently there is no way to do it.
This increase and fix also requires modifying your existing counter collection - so a script is added for same.
How the fix works:
Step 1- Use the script incrementScopePrep.js to change the id of existing counters by adding a suitable suffix
Step 2 - Add the following fields in options :

// Change - 
   var options = {
      id: "member_id",
      inc_field: "id",
      reference_fields: ["city", "district"]
    }
// to 
    var options = {
      id: "member_id",
      inc_field: "id",
      reference_fields: ["city", "district", "country"],
      old_reference_fields: ["city", "district"],
      old_ref_field_suffix: "old" // optional, only needed when you want a custom suffix

    }

Logic involved -
While incrementing, we check if old_reference_fields is set, if yes, then we first try to find new counter as per new reference field, if found, it is incremented, else we create a counter based on seq on older counter (which has a different id)

I implemented this, as I needed this feature urgently. Would love to know opinions about this approach and any other feedback about this PR.

Also would appreciate if eslint preferences of the project are updated so PRs can be automatically formatted as per project standard. Current autofix leads to lots of extra whitespaces as visible in the PR.

@coveralls
Copy link

Coverage Status

Coverage decreased (-11.5%) to 88.489% when pulling 72c4711 on bhanuc:scope_increase into 94b4daf on ramiel:develop.

@coveralls
Copy link

coveralls commented Mar 8, 2019

Coverage Status

Coverage decreased (-11.5%) to 88.489% when pulling ec8ba32 on bhanuc:scope_increase into 94b4daf on ramiel:develop.

@ramiel ramiel self-requested a review June 15, 2019 09:41
@ramiel ramiel changed the base branch from develop to master June 15, 2019 09:41
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.

2 participants