feat(ingestion): add first real-data importer flow
This commit is contained in:
@ -228,3 +228,34 @@ class SavedSearch(models.Model):
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"{self.user} - {self.name}"
|
||||
|
||||
|
||||
class ExternalEntityMapping(models.Model):
|
||||
class EntityType(models.TextChoices):
|
||||
PLAYER = "player", "Player"
|
||||
COMPETITION = "competition", "Competition"
|
||||
TEAM = "team", "Team"
|
||||
PLAYER_SEASON = "player_season", "Player season"
|
||||
|
||||
source_name = models.CharField(max_length=80)
|
||||
entity_type = models.CharField(max_length=30, choices=EntityType.choices)
|
||||
external_id = models.CharField(max_length=140)
|
||||
object_id = models.PositiveBigIntegerField()
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
class Meta:
|
||||
ordering = ["source_name", "entity_type", "external_id"]
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=["source_name", "entity_type", "external_id"],
|
||||
name="uniq_external_entity_mapping",
|
||||
),
|
||||
models.UniqueConstraint(
|
||||
fields=["source_name", "entity_type", "object_id"],
|
||||
name="uniq_external_entity_target",
|
||||
),
|
||||
]
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"{self.source_name}:{self.entity_type}:{self.external_id} -> {self.object_id}"
|
||||
|
||||
Reference in New Issue
Block a user