busy-beaver-dev / busy-beaver

The Chicago Python Community Engagement Slack bot
https://busybeaverbot.com
MIT License
70 stars 23 forks source link

Start getting Upcoming Events feature ready for multitenancy #291

Closed alysivji closed 4 years ago

alysivji commented 4 years ago

Start of #290

What does this do

Why are we doing this

This is the start of getting the Update Events feature working for all users.

How should this be tested

Our end-to-end tests were checking most of this functionality. Had to change a bit of how the tests were called, but if things pass we are good.

Also added a couple of additional end-to-end tests.

Migrations

Added a couple of new tables and added a nullable foreign key relationship on the events table. Will manually migrate those records and run alter column to non-null migration afterwards.

Dependencies

Callouts

n/a

codecov-commenter commented 4 years ago

Codecov Report

Merging #291 into master will decrease coverage by 0.57%. The diff coverage is 75.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #291      +/-   ##
==========================================
- Coverage   95.40%   94.83%   -0.58%     
==========================================
  Files          71       71              
  Lines        2025     2071      +46     
==========================================
+ Hits         1932     1964      +32     
- Misses         93      107      +14     
Impacted Files Coverage Δ
busy_beaver/apps/events/models.py 72.54% <65.85%> (-27.46%) :arrow_down:
busy_beaver/apps/events/cli.py 100.00% <100.00%> (ø)
busy_beaver/apps/events/sync_database.py 100.00% <100.00%> (ø)
busy_beaver/apps/slack_integration/models.py 100.00% <100.00%> (ø)
busy_beaver/models.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 247d262...0af1743. Read the comment docs.

alysivji commented 4 years ago

Ran the following in the Flask console on the Busy Beaver prod box

from busy_beaver.models import Event, SlackInstallation, UpcomingEventsConfiguration, UpcomingEventsGroup
from busy_beaver.extensions import db

workspace_id="T093FC1RC"
s = SlackInstallation.query.filter_by(workspace_id=workspace_id).first()
all_events = Event.query.all()

new_config = UpcomingEventsConfiguration()
new_config.slack_installation = s
new_config.enabled = False
new_config.channel = "C4YLUPP8U"

db.session.add(new_config)
db.session.commit()

group = UpcomingEventsGroup()
group.configuration = new_config
group.meetup_urlname = "_ChiPy_"
group.events = all_events

db.session.add(group)
db.session.commit()