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

Persistent storage solution #132

Merged
merged 34 commits into from
Feb 3, 2025
Merged

Persistent storage solution #132

merged 34 commits into from
Feb 3, 2025

Conversation

Sarahtonein
Copy link
Contributor

Whats new

  • One time Migration script from JSON => Database
  • Database implementation
  • Tests for various discord / database operations
  • Updated to work with either a procfile (Heroku) or docker-compose
  • Updated .env.example
  • new github workflow when pull reqs are made to main / dev
  • Updated operations to work with database tables instead of JSON file.

How to test

  • To test migrations or database operations you can run:
python -m pytest tests/ -v
  • You can also use the test server to run the migration / setup the DB and test out the various functionality if you desire

Following tests in a staging env have been run

  • new event postings
  • upcoming event postings
  • DMing a contributor
  • Listing / Adding / Updating / Removing contributors
  • Creating / voting / concluding proposals
  • Posting proposals to snapshot

Additional
I would like to merge this in after the scrape-props, and quorum-calc PRs have been merged. As this branch is based off of those.

@Sarahtonein Sarahtonein requested a review from bagelface January 17, 2025 05:10
@Sarahtonein Sarahtonein linked an issue Jan 17, 2025 that may be closed by this pull request
@bagelface
Copy link
Contributor

this seems like it got out of sync with dev

@Sarahtonein
Copy link
Contributor Author

this seems like it got out of sync with dev

Merge conflicts resolved

Base automatically changed from scrape-props to dev January 20, 2025 22:42
data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), "data")

contributors_data = load_json_file(os.path.join(data_dir, "contributors.json"))
events_data = load_json_file(os.path.join(data_dir, "events.json"))
Copy link
Contributor

Choose a reason for hiding this comment

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

don't see how this will work with the current "notified_events.json" and "posted_events.json" json files?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We load the JSON and take the separate data and combine it into a dictionary which is then saved to the DB using the defined models

This can be replicated with

def test_migrate_events(test_db):
    """Test migrating events from events.json"""
    data_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "data")
    events_data = load_json_file(os.path.join(data_path, "events.json"))

    if not events_data:
        logger.info("No events data found in events.json")
        assert True
        return

    db_service = DatabaseService(session=test_db)
    result = db_service.migrate_events(events_data)
    assert result >= 0

    events = test_db.query(Event).all()
    assert len(events) >= 0

For example

Copy link
Contributor

@bagelface bagelface left a comment

Choose a reason for hiding this comment

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

a few changes I think to be made, but overall i think this is a much better/simpler approach

@Sarahtonein Sarahtonein requested a review from bagelface February 3, 2025 06:32
Copy link
Contributor

Choose a reason for hiding this comment

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

Docs need a little clean up. There is inconsistent stylizing throughout and probably is a bit wordier than it needs to be. If you agree, can you make a separate issue for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Docs need a little clean up. There is inconsistent stylizing throughout and probably is a bit wordier than it needs to be. If you agree, can you make a separate issue for that.

Agree it can be reduced in size. Will create an issue for this.

Copy link
Contributor

@bagelface bagelface left a comment

Choose a reason for hiding this comment

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

briefly looked over again and this lgtm. lots of code changes so i didn't scrutinize everything they way i'd like to. i just want to get this merged in

@Sarahtonein Sarahtonein merged commit 4762ebe into dev Feb 3, 2025
3 checks passed
@bagelface bagelface deleted the persistent-storage-solution branch February 6, 2025 23:02
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.

Use persistent storage solution
2 participants