Skip to content

Commit d934bef

Browse files
committed
Break out tally syncing into a separate function
1 parent 326fda3 commit d934bef

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

cyhy_commander/wd40.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@ def compute_stuck_cutoff(days):
4444
return date_today - timedelta(days=days)
4545

4646

47+
def sync_tallies(db, owners):
48+
logging.info("Syncing tallies for all affected owners.")
49+
for owner in owners:
50+
logging.debug("Getting tally doc for %s.", owner)
51+
tally = db.TallyDoc.get_by_owner(owner)
52+
if tally is None:
53+
logging.warning(
54+
"No existing tally doc found for %s. Creating a new one.", owner
55+
)
56+
tally = db.TallyDoc()
57+
logging.debug("Syncing tally for %s.", owner)
58+
tally.sync(db)
59+
60+
4761
def main():
4862
args = docopt(__doc__, version="v1.0.0")
4963

@@ -117,14 +131,4 @@ def main():
117131
)
118132

119133
# Sync tallies for affected owners
120-
logging.info("Syncing tallies for all affected owners.")
121-
for owner in owners:
122-
logging.debug("Getting tally doc for %s.", owner)
123-
tally = db.TallyDoc.get_by_owner(owner)
124-
if tally is None:
125-
logging.warning(
126-
"No existing tally doc found for %s. Creating a new one.", owner
127-
)
128-
tally = db.TallyDoc()
129-
logging.debug("Syncing tally for %s.", owner)
130-
tally.sync(db)
134+
sync_tallies(db, owners)

0 commit comments

Comments
 (0)