diff --git a/workers/repositoryactioncounter.py b/workers/repositoryactioncounter.py index d1e951059..bfcf9c78b 100644 --- a/workers/repositoryactioncounter.py +++ b/workers/repositoryactioncounter.py @@ -1,8 +1,9 @@ import logging -from app import app -from data.database import Repository, LogEntry, RepositoryActionCount, db_random_func from datetime import date, timedelta + +from app import app # This is required to initialize the database. +from data.database import Repository, LogEntry, RepositoryActionCount, db_random_func from workers.worker import Worker POLL_PERIOD_SECONDS = 10 @@ -18,20 +19,23 @@ def count_repository_actions(): # Get a random repository to count. today = date.today() yesterday = today - timedelta(days=1) - has_yesterday_actions = (RepositoryActionCount.select(RepositoryActionCount.repository) - .where(RepositoryActionCount.date == yesterday)) + has_yesterday_actions = (RepositoryActionCount + .select(RepositoryActionCount.repository) + .where(RepositoryActionCount.date == yesterday)) - to_count = (Repository.select() - .where(~(Repository.id << (has_yesterday_actions))) - .order_by(db_random_func()).get()) + to_count = (Repository + .select() + .where(~(Repository.id << (has_yesterday_actions))) + .order_by(db_random_func()).get()) logger.debug('Counting: %s', to_count.id) - actions = (LogEntry.select() - .where(LogEntry.repository == to_count, - LogEntry.datetime >= yesterday, - LogEntry.datetime < today) - .count()) + actions = (LogEntry + .select() + .where(LogEntry.repository == to_count, + LogEntry.datetime >= yesterday, + LogEntry.datetime < today) + .count()) # Create the row. try: diff --git a/workers/security_notification_worker.py b/workers/security_notification_worker.py index 0a14bfadb..5e904a39a 100644 --- a/workers/security_notification_worker.py +++ b/workers/security_notification_worker.py @@ -8,12 +8,15 @@ from app import secscan_notification_queue, secscan_api from workers.queueworker import QueueWorker, JobException from util.secscan.notifier import process_notification_data + logger = logging.getLogger(__name__) + _READING_SECONDS = 120 # 2 minutes _PROCESSING_SECONDS = 60 * 60 # 1 hour _LAYER_LIMIT = 100 # The number of layers to request on each page. + class SecurityNotificationWorker(QueueWorker): def process_queue_item(self, data): self.perform_notification_work(data) diff --git a/workers/securityworker.py b/workers/securityworker.py index 73fb7a0c3..6d0920593 100644 --- a/workers/securityworker.py +++ b/workers/securityworker.py @@ -1,8 +1,8 @@ import logging import logging.config +import time import features -import time from peewee import fn