Skip to content

Commit

Permalink
Add ability to reanalyze urls
Browse files Browse the repository at this point in the history
  • Loading branch information
ericholscher committed Sep 26, 2024
1 parent e0c1e40 commit 861b453
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 14 additions & 0 deletions adserver/analyzer/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Django admin configuration for the ad server URL analyzer."""

from django.conf import settings
from django.contrib import admin
from simple_history.admin import SimpleHistoryAdmin

Expand Down Expand Up @@ -44,3 +45,16 @@ class AnalyzedAdvertiserUrlAdmin(SimpleHistoryAdmin):
search_fields = ("url", "keywords")

# Note: may need to use the estimated count paginator if this gets large


if "ethicalads_ext.embedding" in settings.INSTALLED_APPS:
from ethicalads_ext.embedding.tasks import analyze_advertiser_url

@admin.action(description="Re-analyze the selected URLs")
def reanalyze_url(self, request, queryset):
"""Re-analyze the selected URLs."""
for aaurl in queryset:
analyze_advertiser_url.delay(aaurl.url, aaurl.advertiser.slug, force=True)
self.message_user(request, "Re-analyzed selected URLs.")

AnalyzedAdvertiserUrlAdmin.actions = [reanalyze_url]
1 change: 0 additions & 1 deletion adserver/analyzer/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ class AnalyzedAdvertiserUrl(BaseAnalyzedUrl):
flights = models.ManyToManyField(
Flight,
help_text=_("Flights to filter this URL by"),
null=True,
)

class Meta:
Expand Down

0 comments on commit 861b453

Please sign in to comment.