-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add notifications models & admin class * add generators & tests * WIP notifications * test * fix: fixture in test_notification_fixture * wip - adjuns notification api , model & tests * fix get active notification , return generic notifications * update api response, return is_read info * add deduplication notification & adjust notification generation logic * update ceramic cache migrations * update dismissal endpoint * add the expired stamp and on chain expiration notifications * update migrations * feat: backfill expiration and and issuance date in ceramic cache * fix: notification endpoint throwing 500s * fix: expiration notifications * fix: remove unnecesary setter * fix: failing test * fix: verification of returned items * add tests for duplication notifications * allow blank fields for notifications * filter only the recent dedup events & limit tops 20 notifications * add missing tests * wip - adjuns notification api , model & tests * fix migration error --------- Co-authored-by: Gerald Iakobinyi-Pich <nutrina9@gmail.com> Co-authored-by: schultztimothy <schultz.timothy52@gmail.com>
- Loading branch information
1 parent
aaec9b8
commit b00c7be
Showing
16 changed files
with
1,278 additions
and
36 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
37 changes: 37 additions & 0 deletions
37
api/ceramic_cache/management/commands/backfill_ceramic_cache_expiration_and_issuance.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,37 @@ | ||
from django.core.management.base import BaseCommand | ||
from django.db import connection | ||
from ceramic_cache.models import CeramicCache | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Backfills expiration_date and issuance_date from JSON data" | ||
|
||
def handle(self, *args, **options): | ||
batch_size = 10000 | ||
max_id = CeramicCache.objects.latest("id").id | ||
current_id = 0 | ||
|
||
while current_id < max_id: | ||
with connection.cursor() as cursor: | ||
cursor.execute( | ||
""" | ||
UPDATE ceramic_cache_ceramiccache | ||
SET | ||
expiration_date = (stamp::json->>'expirationDate')::timestamp, | ||
issuance_date = (stamp::json->>'issuanceDate')::timestamp | ||
WHERE | ||
id > %s | ||
AND id <= %s | ||
AND (expiration_date IS NULL OR issuance_date IS NULL) | ||
""", | ||
[current_id, current_id + batch_size], | ||
) | ||
|
||
self.stdout.write( | ||
self.style.SUCCESS(f"Backfilled up to id {current_id + batch_size}") | ||
) | ||
|
||
current_id += batch_size | ||
self.stdout.write(f"Processed up to id {current_id}") | ||
|
||
self.stdout.write(self.style.SUCCESS("Data backfill completed successfully")) |
22 changes: 22 additions & 0 deletions
22
api/ceramic_cache/migrations/0021_ceramiccache_expiration_date_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,22 @@ | ||
# Generated by Django 4.2.6 on 2024-06-20 21:31 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("ceramic_cache", "0020_alter_ceramiccache_compose_db_save_status_and_more"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="ceramiccache", | ||
name="expiration_date", | ||
field=models.DateTimeField(db_index=True, null=True), | ||
), | ||
migrations.AddField( | ||
model_name="ceramiccache", | ||
name="issuance_date", | ||
field=models.DateTimeField(db_index=True, null=True), | ||
), | ||
] |
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
18 changes: 0 additions & 18 deletions
18
api/passport_admin/migrations/0006_alter_dismissedbanners_address.py
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.