Remove all references to LogEntry2 from the code
The migration to actually drop the table will go in after this code has been pushed to production
This commit is contained in:
parent
be2cece7b0
commit
6a94eba1a2
8 changed files with 14 additions and 72 deletions
|
@ -4,7 +4,7 @@ from collections import namedtuple
|
|||
from peewee import IntegrityError
|
||||
|
||||
from datetime import date, timedelta, datetime
|
||||
from data.database import (Repository, LogEntry, LogEntry2, RepositoryActionCount,
|
||||
from data.database import (Repository, LogEntry, RepositoryActionCount,
|
||||
RepositorySearchScore, db_random_func, fn)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -52,16 +52,12 @@ def count_repository_actions(to_count):
|
|||
today = date.today()
|
||||
yesterday = today - timedelta(days=1)
|
||||
|
||||
# TODO(LogMigrate): Remove the branch once we're back on LogEntry only.
|
||||
def lookup_action_count(model):
|
||||
return (model
|
||||
actions = (LogEntry
|
||||
.select()
|
||||
.where(model.repository == to_count,
|
||||
model.datetime >= yesterday,
|
||||
model.datetime < today)
|
||||
.where(LogEntry.repository == to_count,
|
||||
LogEntry.datetime >= yesterday,
|
||||
LogEntry.datetime < today)
|
||||
.count())
|
||||
|
||||
actions = lookup_action_count(LogEntry) + lookup_action_count(LogEntry2)
|
||||
try:
|
||||
RepositoryActionCount.create(repository=to_count, date=yesterday, count=actions)
|
||||
return True
|
||||
|
|
Reference in a new issue