From 4f0db6d1bca22bad7ae3f3b93588dcdc3591e8f8 Mon Sep 17 00:00:00 2001 From: Gerald Iakobinyi-Pich Date: Tue, 15 Aug 2023 15:28:48 +0300 Subject: [PATCH] feat(api): saving trusta labs scores to Event table instead of its own table --- api/registry/models.py | 1 + api/trusta_labs/api.py | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/api/registry/models.py b/api/registry/models.py index 771001f46..8e5c1a54e 100644 --- a/api/registry/models.py +++ b/api/registry/models.py @@ -77,6 +77,7 @@ class Event(models.Model): class Action(models.TextChoices): FIFO_DEDUPLICATION = "FDP" LIFO_DEDUPLICATION = "LDP" + TRUSTALAB_SCORE = "TLS" action = models.CharField( max_length=3, diff --git a/api/trusta_labs/api.py b/api/trusta_labs/api.py index b45fe210d..076922108 100644 --- a/api/trusta_labs/api.py +++ b/api/trusta_labs/api.py @@ -3,7 +3,7 @@ from ninja.security import APIKeyHeader from ninja_extra import NinjaExtraAPI, status from ninja_extra.exceptions import APIException -from trusta_labs.models import TrustaLabsScore +from registry.models import Event api = NinjaExtraAPI(urls_namespace="trusta_labs") @@ -55,6 +55,8 @@ def create_trusta_labs_score_db(request, payload: TrustaLabsScorePayload): if payload.score == None: raise TrustaLabsScoreHasNoScore() - TrustaLabsScore.objects.update_or_create( - address=payload.address, sybil_risk_score=payload.score + Event.objects.create( + action=Event.Action.TRUSTALAB_SCORE, + address=payload.address.lower(), + data={"score": payload.score}, )