Skip to content

Commit

Permalink
Fix #1398 Remove uneeded plans iteration on app startup (#1399)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjsimpson authored Aug 28, 2024
1 parent 519ec2a commit 55c5223
Showing 1 changed file with 0 additions and 19 deletions.
19 changes: 0 additions & 19 deletions subscribie/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,25 +219,6 @@ def start_session():
log.debug(
f"Created PriceList with zero rules for currency {currency}"
)
# Ensure every plan (including archived) has a PriceList attached
# for each supported currency
# https://github.com/Subscribie/subscribie/issues/1317
plans = Plan.query.execution_options(include_archived=True).all()
price_lists = (
PriceList.query.all()
) # TODO only get default pricelist for given currency
# since there is danger here that newly created pricelists may be added # noqa: E501
for plan in plans:
# Note we are careful to skip plans which already have a PriceList attached # noqa: E501
# to handle the case of an already updated shop.
if len(plan.price_lists) == 0:
for price_list in price_lists:
log.debug(
f"Adding price_list {price_list.name} to {plan.title}"
)
plan.price_lists.append(price_list)
database.session.commit()
log.debug(f"Added price_list {price_list.name} to {plan.title}")
except sqlalchemy.exc.OperationalError as e:
# Allow to fail until migrations run (flask upgrade requires app reboot)
log.debug(e)
Expand Down

0 comments on commit 55c5223

Please sign in to comment.