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

5841 gaps item import script is incorrect #5883

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

jmbrunskill
Copy link
Contributor

Fixes #5841

πŸ‘©πŸ»β€πŸ’» What does this PR do?

Uses a new mSupply Item Code (created using the python script in this PR) but now is in the spreadsheet as a VLOOKUP.
Volumes are now divided by 1000 to make them in litres
Cold Storage Type look up is improved.

πŸ’Œ Any notes for the reviewer?

If you're brave and want to mostly start again.. you could consider running this.
However might not be correct, definitely don't run it on production..

DELETE from bundled_item;
DELETE from packaging_variant;
DELETE FROM item_variant WHERE id not in (SELECT coalesce(item_variant_id,'noid') from stock_line)
AND id not in (SELECT coalesce(item_variant_id,'noid') from invoice_line)
AND id not in (SELECT coalesce(item_variant_id,'noid') from stocktake_line);
DELETE FROM master_list_line WHERE id not in (SELECT item_link_id FROM stock_line)
AND id not in (SELECT coalesce(item_link_id,'noid') from invoice_line)
AND id not in (SELECT coalesce(item_link_id,'noid') from stocktake_line);
DELETE FROM item_link WHERE id not in (SELECT item_link_id FROM stock_line)
AND id not in (SELECT coalesce(item_link_id,'noid') from invoice_line)
AND id not in (SELECT coalesce(item_link_id,'noid') from stocktake_line)
AND id not in (SELECT coalesce(item_link_id, 'noid') FROM vaccine_course_item);
DELETE FROM item WHERE id not in (select item_id from item_link);

πŸ§ͺ Testing

  • start with afresh GAPS database.
  • Run gaps_item_inserts.sql on your Central Server Postgres database
  • Check that items that previously had been conflated are now fixed
  • Check the looks for cold storage works correctly with new "default" ones setup in the issue
  • Check volumes are correct

πŸ“ƒ Documentation

  • Part of an epic: documentation will be completed for the feature as a whole
  • No documentation required: no user facing changes or a bug fix which isn't a change in behaviour
  • These areas should be updated or checked:
    1.
    2.

@jmbrunskill jmbrunskill linked an issue Dec 20, 2024 that may be closed by this pull request
@github-actions github-actions bot added this to the v2.5.0 milestone Dec 20, 2024
@github-actions github-actions bot added bug Something is borken Team Piwakawaka James, Chris, Carl Severity: High Bugs breaking core functionality or with no/unacceptable workaround. High impact. Next patch release labels Dec 20, 2024
@CarlosNZ CarlosNZ self-assigned this Jan 6, 2025
@@ -0,0 +1,108 @@
import csv
Copy link
Contributor

Choose a reason for hiding this comment

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

As discussed, a comment up the top here to explain the purpose/status of this script would be good

Copy link
Contributor

@CarlosNZ CarlosNZ left a comment

Choose a reason for hiding this comment

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

Holding off on further review pending @jmbrunskill looking at updating the spreadsheet to include item ID, as discussed IRL

@jmbrunskill
Copy link
Contributor Author

jmbrunskill commented Jan 6, 2025

@CarlosNZ I've decided that there's too many ids to manage in that spreadsheet.
However, I've changed the spreadsheet to use the item_code as the unique lookup, which means we could change item names without loosing our link to the item_id in the id_lookup.json if we want to change the item_codes again then they'll get new ids, let's cross that bridge if we need too. At that point we could add the UUIDs in if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is borken Severity: High Bugs breaking core functionality or with no/unacceptable workaround. High impact. Next patch release Team Piwakawaka James, Chris, Carl
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GAPS item import script is incorrect
2 participants