-
Notifications
You must be signed in to change notification settings - Fork 75
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
Refactor Entities.createVersion #1013
Conversation
9b3acdf
to
242bd29
Compare
c111d6b
to
20573bd
Compare
d0f0680
to
7f59e5d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interactive review with @matthew-white
lib/model/query/entities.js
Outdated
@@ -37,15 +49,13 @@ const nextval = sql`nextval(pg_get_serial_sequence('entities', 'id'))`; | |||
const createNew = (dataset, partial, subDef, sourceId, userAgentIn) => ({ one, context }) => { | |||
let creatorId; | |||
let userAgent; | |||
let subDefId; | |||
|
|||
// Set creatorId and userAgent from submission def if it exists | |||
if (subDef != null && subDef.id != null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look into why subDef.id != null
is checked in the first place. If it is needed, it should be needed in the audit function, too.
lib/model/query/entities.js
Outdated
let userAgent; | ||
|
||
// Set creatorId and userAgent from submission def if it exists | ||
if (subDef != null && subDef.id != null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check if this is needed subDef.id != null
here, too.
@@ -845,6 +845,14 @@ describe('worker: entity', () => { | |||
person.currentVersion.version.should.equal(2); | |||
}); | |||
|
|||
await asAlice.get('/v1/projects/1/datasets/people/entities/12345678-1234-4123-8234-123456789abc/audits') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test of audit log content deserves its own test/set of tests.
Addresses some clunkiness in #1005 but I wanted to put it in a separate PR so the meaning of #1005 would be clearer.
There's a 2x2 square of situations and I tried to make the via submission vs. API cases more similar.
[creating entities, updating entities] x [via submission, via API]
Via API:
createNew.audit
andcreateVersion.audit
, which checks that submission def was not providedVia submission:
What has been done to verify that this works as intended?
Why is this the best possible solution? Were any other approaches considered?
How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
Does this change require updates to the API documentation? If so, please update docs/api.md as part of this PR.
Before submitting this PR, please make sure you have:
make test-full
and confirmed all checks still pass OR confirm CircleCI build passes