-
Notifications
You must be signed in to change notification settings - Fork 412
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Heal all identities with blank traits
- Loading branch information
Showing
3 changed files
with
104 additions
and
2 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
api/edge_api/management/commands/ensure_identity_traits_blanks.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,28 @@ | ||
import logging | ||
from typing import Any | ||
|
||
from django.core.management import BaseCommand | ||
|
||
from environments.dynamodb import DynamoIdentityWrapper | ||
|
||
identity_wrapper = DynamoIdentityWrapper() | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class Command(BaseCommand): | ||
def handle(self, *args: Any, **options: Any) -> None: | ||
for identity_document in identity_wrapper.query_get_all_items(): | ||
should_write_identity_document = False | ||
if identity_traits_data := identity_document.get("identity_traits"): | ||
for trait_data in identity_traits_data: | ||
if "trait_value" not in trait_data: | ||
should_write_identity_document = True | ||
trait_data["trait_value"] = "" | ||
if should_write_identity_document: | ||
identity_wrapper.put_item(identity_document) | ||
self.stdout.write( | ||
f"Fixed identity id={identity_document['identity_uuid']}", | ||
) | ||
self.stdout.write(self.style.SUCCESS("Finished.")) |
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