Skip to content

Commit

Permalink
feat(api): saving trusta labs scores to Event table instead of its ow…
Browse files Browse the repository at this point in the history
…n table
  • Loading branch information
nutrina authored and lucianHymer committed Aug 15, 2023
1 parent b39d1a8 commit 4f0db6d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions api/registry/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 5 additions & 3 deletions api/trusta_labs/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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},
)

0 comments on commit 4f0db6d

Please sign in to comment.