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

deriveReducedPointList(data) function #197

Open
9 tasks
ddfridley opened this issue Aug 30, 2024 · 0 comments
Open
9 tasks

deriveReducedPointList(data) function #197

ddfridley opened this issue Aug 30, 2024 · 0 comments

Comments

@ddfridley
Copy link
Contributor

ddfridley commented Aug 30, 2024

deriveReducedPointList(data) where data is the property of the DeliberationContext.
takes: data.pointList and data.groupIdsList and creates/updates data.reducedPointList

groupIds is a list of ids that should be in a group, The first one is the one that should be the point in the reducedPointList object, and the remaining ones should be turned into entries in groupdDocs.

any docs that are in pointList, but not anywhere in any group, should be in reducedPointList with groupeDocs: undefined

the Ids in groupIds can be assumed to all be in pointList. If one is not - log an error and do the best you can. (don't throw errors in production).

pointList: [pointId, pointId, ...]
groupIdsList: [[pointId, pointId],[pointId, ..., pointId]]

reducedPointList=[ {pointDoc, groupedDocs: [pointDoc]} ]

If data.pointList and data.groupIdsList have not changed, data.reducedPointList should not change.

If either has changed, create a new version of reducedPointList, then go through each entry and see if the contents have changed. If no changed, then copy the old entry into the new array.

If at the end of comparing old and new, nothing has changed, return the original array.

See derive-review-points for an example, and general discussion of how a "deriver" uses the ref of an object to determine if something has changed, and to indicate if something has changed.

Create jest tests for:

  • pointList is empty or doesn't exist. (results in an empty array)
  • groupIdList is empty or doesn't exist. (creates array of object based on point list with grooupedDocs undefined}
  • pointList has 10 items in it, groupIdList has an array of 2 groups. One with 2 pointIds, one with 3 pointIds.
  • it is called with no changes to the input
  • it is called and one of the groups has changed to have one more point in it.
  • it is called and one of the groups has changed to have one fewer points in it.
  • it is called and one of the groups has been removed.
  • it is called, and one of the points in pointList has been updated - so it has a new ref - reducedPointList ref should be changed, and only the ref to the element with the changed point should be changed.
  • is is called and one of the groups has a new ref, but hasn't actually changed. -- reducedPointList should not change
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

1 participant