rebuild_all() and Season.build() printing notification multiple times

This commit is contained in:
Xevion
2020-01-20 16:34:36 -06:00
parent da69e4812a
commit 2fbfcb85a5
2 changed files with 6 additions and 3 deletions

3
.gitignore vendored
View File

@@ -4,6 +4,7 @@ migrations/**
app.db app.db
keys.json keys.json
process.py process.py
app.db-journal
# Byte-compiled / optimized / DLL files # Byte-compiled / optimized / DLL files
__pycache__/ __pycache__/
@@ -133,4 +134,4 @@ venv.bak/
dmypy.json dmypy.json
# Pyre type checker # Pyre type checker
.pyre/ .pyre/

View File

@@ -5,7 +5,7 @@ from bs4 import BeautifulSoup
from app import db, login from app import db, login
episodes = [5, 6, 22, 23, 14, 26, 24, 24, 24, 23] episodes = [5, 6, 22, 23, 14, 26, 24, 24, 24, 23]
quotePattern = r'([\w\s\.\',-\[\]\d&\"]+):(.+)' quotePattern = r'([\w\s\.\',-\[\]\d&\"#]+):(.+)'
class Season(db.Model): class Season(db.Model):
id = db.Column(db.Integer, primary_key=True) id = db.Column(db.Integer, primary_key=True)
@@ -18,7 +18,7 @@ class Season(db.Model):
def build(self): def build(self):
"""runs build operations on every Episode under this season""" """runs build operations on every Episode under this season"""
for episode in range(1, episodes[self.id - 1] + 1): for episode in range(1, episodes[self.id - 1] + 1):
print('Running build()') print(f'Running build() on Season {self.id}')
ep = Episode.query.filter_by(season_id=self.id, number=episode).first() ep = Episode.query.filter_by(season_id=self.id, number=episode).first()
if ep is None: if ep is None:
# Add the episode, then build # Add the episode, then build
@@ -45,6 +45,8 @@ class Season(db.Model):
@staticmethod @staticmethod
def rebuild_all(): def rebuild_all():
"""runs build() on all Season objects in database""" """runs build() on all Season objects in database"""
for season in Season.query.all():
season.build()
@property @property
def episodes(self): def episodes(self):