Skip to content

Commit

Permalink
OPEN-3194: Remove frequent common Events generated by the open data p…
Browse files Browse the repository at this point in the history
…ortal using a background task
  • Loading branch information
thriuin committed Apr 17, 2024
1 parent 023c60a commit 254efd2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions search/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,14 @@ def save_search_logs_to_file():
log_writer.writerow(log_entry)
log.delete()
logger.info(f'{older_logs.count()} log entries purged.')


@shared_task()
def purge_search_info_events():

logger = logging.getLogger(__name__)

one_hour_ago = datetime.today() - timedelta(hours=1)
old_ckan_events = Event.objects.filter(log_timestamp__lte=one_hour_ago, component_id='data_import_ckan_json.remote', category='success')
for event in old_ckan_events:
event.delete()

0 comments on commit 254efd2

Please sign in to comment.