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

Bulk entity creation via API #1070

Merged
merged 13 commits into from
Feb 24, 2024
Merged

Bulk entity creation via API #1070

merged 13 commits into from
Feb 24, 2024

Conversation

ktuite
Copy link
Member

@ktuite ktuite commented Jan 11, 2024

Closes getodk/central#573

Uses POSTing to existing /v1/projects/1/datasets/people/entities endpoint so it can handle

  • single entities with just {uuid, label, data}
  • multiple entities with {entities: [{}, {}], source: {name, size}}

For the source object,

  • source is required
  • name within source is required (not sure if it should be but it will help with displaying on the front end...)
  • size (meant to represent file size)

I was thinking about how to handle the bulk SQL insert and decided it was easiest to think/build two separate queries, one for the entities table and another for the entity_defs table. Elsewhere the code, we have complex queries for inserting a single entity's data into both tables at once, but it didn't seem reasonable to try to do that with multiple entities.

What has been done to verify that this works as intended?

Tests, trying it out.

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.

Documentation is included in this PR!!

Before submitting this PR, please make sure you have:

  • run make test-full and confirmed all checks still pass OR confirm CircleCI build passes
  • verified that any code from external sources are properly credited in comments or that everything is internally sourced

@ktuite ktuite force-pushed the ktuite/bulk_append branch 3 times, most recently from 58210fc to e295d23 Compare January 30, 2024 20:40
lib/model/query/entities.js Outdated Show resolved Hide resolved
lib/resources/entities.js Outdated Show resolved Hide resolved
@ktuite ktuite marked this pull request as ready for review February 13, 2024 20:56
Copy link
Member Author

@ktuite ktuite left a 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/resources/entities.js Outdated Show resolved Hide resolved
lib/resources/entities.js Outdated Show resolved Hide resolved
lib/model/query/entities.js Outdated Show resolved Hide resolved
lib/model/query/entities.js Outdated Show resolved Hide resolved
lib/model/query/entities.js Show resolved Hide resolved
test/integration/api/entities.js Outdated Show resolved Hide resolved
test/integration/api/entities.js Outdated Show resolved Hide resolved
test/integration/api/entities.js Outdated Show resolved Hide resolved
test/integration/api/entities.js Show resolved Hide resolved
test/integration/api/entities.js Show resolved Hide resolved
@ktuite ktuite merged commit f98187d into master Feb 24, 2024
5 checks passed
@ktuite ktuite deleted the ktuite/bulk_append branch February 24, 2024 02:58
@ktuite ktuite mentioned this pull request Feb 27, 2024
6 tasks
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.

Create entities in bulk via API (JSON)
2 participants