Skip to content

Commit

Permalink
Merge pull request #8 from jhrcook/model-attrs
Browse files Browse the repository at this point in the history
Updated model attributes
  • Loading branch information
jhrcook authored Mar 13, 2021
2 parents 7a69854 + 55ef624 commit bd466db
Show file tree
Hide file tree
Showing 3 changed files with 223 additions and 41 deletions.
2 changes: 2 additions & 0 deletions .mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[mypy]
ignore_missing_imports = True
37 changes: 37 additions & 0 deletions database_migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env python3

import main


def introduce_active_attribute_to_coffee_bags():
num_bags = 0
for bag in main.coffee_bag_list():
num_bags += 1
info = main.convert_bag_to_info(bag)
main.coffee_bag_db.put(info)
print(f"Converted {num_bags} bags.")


def add_seconds_attribute_to_coffee_uses():
coffee_uses = main.coffee_use_dict()
n = 0
for key, coffee_use in coffee_uses.items():
try:
main.coffee_use_db.update({"_seconds": coffee_use._seconds}, key=key)
n += 1
except Exception as err:
print(f"Error: {err}")
print("CoffeeUse:")
print(coffee_use.dict())
return
print(f"Converted {n} uses.")


def migrate():
# introduce_active_attribute_to_coffee_bags()
# add_seconds_attribute_to_coffee_uses()
print("Done")


if __name__ == "__main__":
migrate()
Loading

0 comments on commit bd466db

Please sign in to comment.