Skip to content

Commit

Permalink
Remove old function
Browse files Browse the repository at this point in the history
  • Loading branch information
brianjp93 committed Oct 15, 2024
1 parent f9540ca commit c6983bd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 18 deletions.
2 changes: 1 addition & 1 deletion fly.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ kill_timeout = "5s"
[processes]
beat = "celery -A lolsite beat -l INFO"
web = "gunicorn --bind :8000 --workers 10 lolsite.wsgi:application"
worker = "celery -A lolsite worker --concurrency=12 --loglevel=INFO"
worker = "celery -A lolsite worker --concurrency=20 --loglevel=INFO"

[[services]]
protocol = "tcp"
Expand Down
19 changes: 2 additions & 17 deletions match/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,21 +331,6 @@ def import_recent_matches(
return import_count


@app.task(name="match.tasks.import_matches_for_popular_accounts")
def import_matches_for_popular_accounts(n=100):
now = timezone.now()
week = (now - timedelta(days=7)).date()
qs = Summoner.objects.all().annotate(
views=Sum('pageview__views', filter=Q(pageview__bucket_date__gte=week))
).order_by('-views').filter(views__isnull=False, views__gt=1)
for i, summoner in enumerate(qs[:n]):
logger.info(f"Importing matches for {summoner.name} ({i}) with {summoner.views=}") # type: ignore
try:
import_recent_matches(0, 50, summoner.puuid, summoner.region)
except Exception:
logger.exception("Error while importing matches.")


@app.task(name="match.tasks.bulk_import")
def bulk_import(puuid: str, last_import_time_hours: int = 24, count=200, offset=10):
now = timezone.now()
Expand Down Expand Up @@ -429,7 +414,7 @@ def get_jobs(qs, start_time):
summoner.huge_match_import_at = import_time
summoner.save(update_fields=["huge_match_import_at"])

for _ in celery_task_pool(get_jobs(qs.iterator(2000), thresh), 10):
for _ in celery_task_pool(get_jobs(qs.iterator(2000), thresh), pool_size=15):
i += 1
if i % 100 == 0:
elapsed = time.perf_counter() - elapsed_start
Expand All @@ -438,7 +423,7 @@ def get_jobs(qs, start_time):
logger.info(f"Finished importing {i} participants of about {count}.")
logger.info(f"Estimated time remaining for query loop: {estimated_remaining} minutes")

logger.info(f"{i} total summoner games imported.")
logger.info(f"Games for {i} summoners imported.")
logger.info("huge_match_import_task finished.")


Expand Down

0 comments on commit c6983bd

Please sign in to comment.