-
Notifications
You must be signed in to change notification settings - Fork 2
Create worker to sync basefields #1259
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
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1259 +/- ##
==========================================
- Coverage 87.36% 87.30% -0.06%
==========================================
Files 199 209 +10
Lines 2707 2876 +169
Branches 387 408 +21
==========================================
+ Hits 2365 2511 +146
- Misses 342 365 +23 ☔ View full report in Codecov by Sentry. |
de7e177
to
daba11e
Compare
@slifty @jasonaowen finally got this (mostly) tested! I'll try and get to full coverage before merging but I've taken this out of draft status as I believe this is ready for review, with one caveat: I think the entity name needs to be changed :/ I got very deep into this before considering that. It's not a particularly intuitive name, and it feels awkward to write out in documentation. I figured I'd wait for your reviews before changing. Ready and willing to refactor everything as soon as we decide on a better name for the entity/task. |
1f27e03
to
6254d60
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.
Some thoughts on naming and a few little things
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.
Awesome work, @hminsky2002!
6254d60
to
9704bee
Compare
4076491
to
4b20c24
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.
Good progress; a fair bit of feedback. If it would help to talk through it let me know.
return; | ||
} | ||
|
||
try { |
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.
Am I missing a test? Codecov is saying that all of these lines are covered... but I'm not seeing any tests that actually run anything.
} | ||
resolve(parsedData); | ||
} catch (err) { | ||
reject( |
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.
Will reject
cause it to try again? Do we want it to try again if the format is unexpected?
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.
My understanding is that on promise rejection, the copyBasefields function that calls the fetch intercepts the failure and updates the status of the task, which I believe means that it will not get called again (which I think is what we want, so long as it is logged!)
ecb1b38
to
a2fd57a
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.
This is the first major PR linted with SQLFluff, so we have a few things to shake out!
e0873cc
to
f3256a6
Compare
c4ead92
to
3dbd926
Compare
@slifty re-requesting review here (and apologies for letting yours hang for so long) -- agreed with all your notes regarding language of variables and the status_updating being handled by the database itself (very cool!) -- major thing left to discuss is nock with fetch as i mentioned above, interested to hear your take on the matter! |
21404ab
to
aab573d
Compare
@hminsky2002, you can try Nock's beta for native fetch support. We are about to release it (v14) soon :) |
aab573d
to
ca4f9f0
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.
This is looking good, @hminsky2002! Thanks for working on this.
src/database/queries/baseFieldsCopyTasks/selectWithPagination.sql
Outdated
Show resolved
Hide resolved
This looks good and Jason has reviewed the latest closely!
54fa64e
to
0b9f4a5
Compare
This commit adds an upsert query and operation for basefields, following the pattern laid out for basefield localizations. We dont want the synchronization to be destructive, so we update on shortcode.
This commit creates the new entity 'BaseFieldsCopyTask', along with the necessary database operations to access and update them. BaseFieldsCopyTasks, like BulkUploadTasks, are intended to serve as user-accessible entities that log the status of a basefield copy job between a local and remote pdc instance. In order to use nock, our current http mocking framework, for testing, we needed to use an alternative to the default node fetch package, as that is incompatible with nock. We decided in the PR to add the node-fetch package, which is compatible with nock. Notably we added it at an older version, which per the node-fetch documentation is necessary for commonJs compatiblity (https://github.com/node-fetch/node-fetch#commonjs)
0b9f4a5
to
f1f2ebb
Compare
This PR introduces a new worker to the API, which allows an administrator to synchronize BaseField data from a remote service instance to a local one. It heavily follows the patterns already laid out for the bulkUpload task/worker, creating and storing an entity (
SyncBaseField
) in the database to track the status of a synchronization job. Joyously, this functionality means we no longer need a seed file (see commit 2c8879b).Closes #756