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

Extend kit creation code, barcodes.kit table for daklapack kits #356

Merged
merged 10 commits into from
Jul 2, 2021

Conversation

AmandaBirmingham
Copy link
Collaborator

Refactor most of create_kits function in admin_repo.py into private functions that can be used by both create_kits and a new create_kit (note singular :) function that takes in barcodes, box id, and kit name specified by Daklapack (instead of generating them internally). Extend barcodes.kit table to contain a box id separate from a kit id as well as two different fedex tracking numbers (instead of one).

… a kit with it, using refactored innards of create_kits. Update tests accordingly
…code that creates kits to fill it (with either explicitly supplied values or otherwise with kit uuids). updated tests accordingly
…e-api into daklapack_api

� Conflicts:
�	microsetta_private_api/db/patches/0076.sql
ALTER TABLE barcodes.kit RENAME COLUMN fedex_tracking TO outbound_fedex_tracking;
ALTER TABLE barcodes.kit ADD COLUMN inbound_fedex_tracking varchar NULL;
ALTER TABLE barcodes.kit ADD COLUMN box_id varchar NULL;
UPDATE barcodes.kit SET box_id = kit_uuid;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also drop the column kit_uuid?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand the thinking here. In future, some kits will have a box_id that is distinct from their kit_uuid; in those cases, that box_id will be generated by Daklapack. Nonetheles, for all kits we definitely need a unique kit id that we can use as a primary key, and I argue it would be too risky to use an externally generated id (like the Daklapack-created box_id) as our internal primary key. Therefore I think we need a kit_uuid for each kit even in cases where that kit also has a (different) box_id.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh I see, that makes sense!

Comment on lines +736 to +738
kit_names = self._generate_novel_kit_names(number_of_kits, kit_prefix)
kit_name_and_barcode_tuples_list, new_barcodes = \
self._generate_novel_barcodes(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dhakim87, do you think these should use lock?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure- I don't think they need it? What resource do you think needs to be locked/what other operation would this conflict with?

I think the postgres lock mechanism should be thought of as using synchronized/lock blocks in java or C#: we need lock access to particular resource when there are multiple workflows that all need to read and then write based on what was snapshotted, and all access to that resource must be locked.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, so assuming we rarely if ever expect concurrent transactions, and the likelihood of a conflict in ID generation is low, then we should be good

"(kit_id) "
"VALUES (%s)", [(n, ) for n in names])
"(kit_uuid, kit_id, box_id) "
"VALUES (%s, %s, %s)", barcode_kit_inserts)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do the fedex tracking numbers come later?

Copy link
Collaborator Author

@AmandaBirmingham AmandaBirmingham Jul 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wasade Good catch! I had failed to unshelve one set of changes for this PR [facepalm], which bring in address and fedex tracking numbers ... they are here now :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@wasade wasade merged commit 93e2b52 into master Jul 2, 2021
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.

3 participants