-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Admin1 geo code to database - Add sync logic to pull data from go api (currently stage) * Add tagging from circle and geocodes as fallback * User _value2member_map_ to check geocode type is supported by using enum * Fix mapping value issue * Use go-api prod for geo data sync * Skip circle polygon filter if tagged by normal polygons * Use camelCase for argo hooks * Add support for custom python script in argoHooks * Add missing cronjobs for WEEKLY and MONTHLY subscription email * Add total_alerts_count node for subscription alerts count - Fix filtering issue for subscription alerts * Disable querystring_auth for S3 static bucket * Add test additional dataset for subscription/alert tagging test * Add multiple queue: feeds and default * Add celery flower * Fix read me and email template * Typos fix --------- Co-authored-by: barshathakuri <[email protected]>
- Loading branch information
1 parent
fef661d
commit df6b0a2
Showing
30 changed files
with
682 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
apps/cap_feed/migrations/0012_admin1_emma_id_admin1_fips_code_admin1_nuts1_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Generated by Django 4.2.13 on 2024-12-02 15:36 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('cap_feed', '0011_alter_alertinfo_category_alter_alertinfo_certainty_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='admin1', | ||
name='emma_id', | ||
field=models.CharField(blank=True, db_index=True, help_text='Meteoalarm EMMA_ID', max_length=10, null=True, verbose_name='emma_id'), | ||
), | ||
migrations.AddField( | ||
model_name='admin1', | ||
name='fips_code', | ||
field=models.PositiveIntegerField(blank=True, db_index=True, help_text='USA FIPS Code', null=True, verbose_name='fips_code'), | ||
), | ||
migrations.AddField( | ||
model_name='admin1', | ||
name='nuts1', | ||
field=models.CharField(blank=True, db_index=True, help_text='Nomenclature of Territorial Units for Statistics 1', max_length=3, null=True, verbose_name='nuts1'), | ||
), | ||
migrations.AddField( | ||
model_name='admin1', | ||
name='nuts2', | ||
field=models.CharField(blank=True, db_index=True, help_text='Nomenclature of Territorial Units for Statistics 2', max_length=4, null=True, verbose_name='nuts2'), | ||
), | ||
migrations.AddField( | ||
model_name='admin1', | ||
name='nuts3', | ||
field=models.CharField(blank=True, db_index=True, help_text='Nomenclature of Territorial Units for Statistics 3', max_length=5, null=True, verbose_name='nuts3'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from asgiref.sync import sync_to_async | ||
from django.db import models | ||
from django.utils.functional import cached_property | ||
from strawberry.dataloader import DataLoader | ||
|
||
from .models import SubscriptionAlert | ||
|
||
|
||
def load_alert_count_by_subscription(keys: list[int]) -> list[int]: | ||
qs = ( | ||
SubscriptionAlert.objects.filter(subscription_id__in=keys) | ||
.order_by() | ||
.values('subscription_id') | ||
.annotate( | ||
alert_count=models.Count('alert'), | ||
) | ||
.values_list('subscription_id', 'alert_count') | ||
) | ||
_map = {subscription_id: alert_count for subscription_id, alert_count in qs} | ||
return [_map.get(key, 0) for key in keys] | ||
|
||
|
||
class SubscriptionDataloader: | ||
|
||
@cached_property | ||
def load_alert_count_by_subscription(self): | ||
return DataLoader(load_fn=sync_to_async(load_alert_count_by_subscription)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.