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
Function to generate Flow types from edit data #1616
Conversation
Note that we can use |
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.
LGTM but I didn't test
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.
Successfully tested on production database with “Reorder relationships” edits (type ID = 99).
Would it make sense to have a wrapper script that uses PROD_STANDBY
from DBDefs
?
That would be nice to mention the command generating the added flow type in second commit too.
f93d345
to
658b427
Compare
Added a wrapper script for that (and updated the commit message/PR description with instructions). It sets Also added |
"pg": "8.3.3", | ||
"pg-cursor": "2.3.3", |
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.
I'm also using these in my json-dumps rework.
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.
./script/generate_edit_data_flow_type.js --edit-type 92
returned:
/musicbrainz-server/root/utility/generateFlowType.js:37
(isEditDataTypeInfo ?? parent.isEditDataTypeInfo);
^
SyntaxError: Unexpected token ?
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/musicbrainz-server/script/generate_edit_data_flow_type.js:23:28)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
using Node v10.19.0
currently installed in MusicBrainz Docker.
658b427
to
c774398
Compare
This will be used to connect directly to postgres from Node.js.
This will be used to connect directly to postgres from Node.js.
A SQL function, edit_data_type_info(), is added that generates "type info" for a single column of edit data. A script, script/generate_edit_data_flow_type.js, is added which takes an edit type, selects edit_data_type_info() for every row of edit data for that type, and outputs a single merged Flow type representing the edit data overall for that type. For example: ./script/generate_edit_data_flow_type.js --edit-type 92 Generates a Flow type for EDIT_RELATIONSHIP_DELETE. The PROD_STANDBY database must be configured in DBDefs.pm to use this utility. The underlying code used to build the Flow type may also be useful to generate Flow types for other JSON data, e.g. entities.json, so I've added script/generate_json_flow_type.js for this more general purpose too. Here's an example invoking that script: cat entities.json | jq -c | script/generate_json_flow_type.js (This expects the JSON object on a single line, so `jq -c` is used to compact the data first.)
Command used: ./script/generate_edit_data_flow_type.js --edit-type 92
c774398
to
8402f87
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.
Works fine now. Code looks good too. Maybe document scripts also in HACKING.md
?
I wasn't sure where to put that so I made a general Flow section. Have a quick look. :) |
74ef207
to
319df9c
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.
Each time I approve this pull request, there are new additions, so I approve it again!
319df9c
to
583a592
Compare
OK, I'll commit the |
A SQL function,
edit_data_type_info()
, is added that generates "type info" for a single column of edit data.A script, script/generate_edit_data_flow_type.js, is added which takes an edit type,
selects edit_data_type_info()
for every row of edit data for that type, and outputs a single merged Flow type representing the edit data overall for that type.For example:
Generates a Flow type for
EDIT_RELATIONSHIP_DELETE
.The
PROD_STANDBY
database must be configured in DBDefs.pm to use this utility.The underlying code used to build the Flow type may also be useful to generate Flow types for other JSON data, e.g. entities.json, so I've added script/generate_json_flow_type.js for this more general purpose too. Here's an example invoking that script:
(This expects the JSON object on a single line, so
jq -c
is used to compact the data first.)I've committed the type generated for root/edit/details/RemoveRelationship.js as an example.
I think this will help with two things:
build_display_data
etc. into JS.