openreferral / ServiceNet

7 stars 6 forks source link

Duplication of Updated Record #1699

Open EnriqueCorado opened 3 years ago

EnriqueCorado commented 3 years ago

Bug description For the NC pilot, I am adding the social media links, and once I save, on the homepage I see two of the sam record. Tried to edit a different record, added social media links, and record shows up twice in the own section panel

To Reproduce Steps to reproduce the behavior:

  1. login to account on slack
  2. Look at the owned records
  3. Update the social media links
  4. click "I'm finished"
  5. once the user is back on home screen, a duplication of the record shows

Dev note: John - these users are part of a 'User group' so are potentially looking at records from other users in their group. My gut says it's a bug with how records are returned from the user group ties since the IDs of the two records are the same

Actual result

Screenshot 2021-02-05 081748

Expected behavior only show the record updated not a duplicate

Screenshots/gifs

Verified on: OS: Browser: Google Chrome Version: Version 88.0.4324.150 (Official Build) (64-bit)

Additional context DEV note:

Dev Signoffs

QA Signoffs

Product Signoff

johnhbenetech commented 3 years ago

Dev note: these users are part of a 'User group' so are potentially looking at records from other users in their group.

My gut says it's a bug with how records are returned from the user group ties since the IDs of the two records are the same

EnriqueCorado commented 3 years ago

updated comment on task

awalkowiak commented 3 years ago

@johnhbenetech, @EnriqueCorado Yup seems like the issue here is the user group. The same record is returned from two different users within the same group (I managed to reproduce this locally). However, I don't have a quick fix for that one. I thought that adding distinct would help here, but turns out it is not enough. How urgent this bug is? Can this wait till Monday?

EnriqueCorado commented 3 years ago

@awalkowiak it can wait till Monday. thank you for taking a look so quickly

awalkowiak commented 3 years ago

Turns out that this is a bit more complex issue. That is related to our architectural decisions related to the User Profile - Organization linkage.

If a user does update to not his record (but from his User Group), then this user is also added/assigned to this specific record - organization (user is added to the user_profile_organizations table). Because we are pulling records for a provider that is in a specific User Group, together with records from other users within the Group, the duplicate record occurs. I tried adding simple distinct, but because both records have two different user profiles (after join) assigned they are treated as different records (that's why both records have different 'owners' - below the last update date on the record card). Additionally, we are also not storing the information about who did the last update.

Potential solution: Perhaps we should store information about the updating user (in Organization relation to UserProfile updatedBy - if it'd be null, then it'd mean that uploading provider-organization like Eden, UWBA, or other made the last update) and only 'real' owner user would be stored in user_profile_organizations table (without adding 'new owner' on record update within the User Group).

@jkondrat Do you have any other potential solutions to this issue? What do you think about this one?

@johnhbenetech, @EnriqueCorado what do you think about it?

jkondrat commented 3 years ago

@awalkowiak sound good to me, unless updatedBy is sufficient, we can also add the 'creator' or 'owner' field to the Organization

abaranowska1 commented 3 years ago

Tested with success

EnriqueCorado commented 3 years ago

@abaranowska1 why are we not showing all records owned also under the search bar?

Screenshot 2021-02-16 074314
johnhbenetech commented 3 years ago

@EnriqueCorado that's never been how the functionality worked.

Records where you = owner appear above search

Records where owner = anyone else appear below search

Prior to this change we erroneously allowed for more than one owner, so in those cases a record would show in both places. Now that we limit the record to 1 owner the functionality works as specified.

If we would like to change the logic used to populate the bottom section that would need to be a separate task