theastropath / turbot

A Discord bot for tracking Animal Crossing: New Horizons turnip prices and fossil collections
MIT License
8 stars 1 forks source link

Refactors data store to sqlite #171

Closed lexicalunit closed 4 years ago

lexicalunit commented 4 years ago

It's ready!

Screen Shot 2020-05-13 at 6 13 06 PM Screen Shot 2020-05-13 at 6 12 57 PM

TODO:

lexicalunit commented 4 years ago

Changes:

What this gives us:

In the future we could now allow people to provide a database configuration and let them select the database they want to use. In development/tests we could use a sqlite database. Then in CI we could have a matrix that tests against sqlite and postgres. And in production people could optionally run against postgres. We'd need to have something like postgres in the future if we wanted to support multiple servers.

lexicalunit commented 4 years ago

We might also want to re-visit how we're using data.commit() in the future as wholesale overwriting the table data isn't what we want to have happen. Maybe pandas is smart enough not to be doing that 🤷‍♀️ In any case, we can probably refactor some of the commands at some point in the future to do things more optimally.

Edit: Fixed this!

lexicalunit commented 4 years ago

Updated PR to add Alembic database migrations so that we can easy migrate database over time.

I also added the first migration beyond the initial revision to add relationships to our data models. This could be super helpful in the future in refactoring things to be really nice. For example with relationship we can do things like:

user = get_user()
user.prices # get all this user's prices thru the relationship
user.fossils # get all this user's fossils thru the relationship
etc...
codecov-io commented 4 years ago

Codecov Report

Merging #171 into master will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##            master      #171    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files            2         4     +2     
  Lines          109       214   +105     
  Branches        13        12     -1     
==========================================
+ Hits           109       214   +105     
Impacted Files Coverage Δ
src/turbot/assets.py 100.00% <100.00%> (ø)
src/turbot/data.py 100.00% <100.00%> (ø)
...rsions/versions/1afdca2a2389_adds_relationships.py 100.00% <100.00%> (ø)
...versions/versions/cb8aa87d74cb_initial_revision.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 8e50568...3b13fc0. Read the comment docs.

lexicalunit commented 4 years ago

Also added docker documentation and fixed up some issues with #154.

lexicalunit commented 4 years ago

Added support for TURBOT_DB_URL so that we can theoretically use any database we want now.