frogress/frog_api/models.py

74 lines
2.2 KiB
Python
Raw Normal View History

2022-08-19 10:35:05 +00:00
from django.db import models
2022-08-20 03:33:23 +00:00
# Example: OOT
2022-08-19 10:35:05 +00:00
class Project(models.Model):
id = models.AutoField(primary_key=True)
created_on = models.DateTimeField(auto_now_add=True)
last_updated = models.DateTimeField(auto_now=True)
slug = models.SlugField(max_length=255, unique=True)
name = models.CharField(max_length=255)
auth_key = models.CharField(max_length=255)
2022-08-20 03:33:23 +00:00
def __str__(self) -> str:
return self.slug
2022-08-19 10:35:05 +00:00
2022-08-20 03:33:23 +00:00
# Example: US 1.0
2022-08-19 10:35:05 +00:00
class Version(models.Model):
id = models.AutoField(primary_key=True)
created_on = models.DateTimeField(auto_now_add=True)
last_updated = models.DateTimeField(auto_now=True)
2022-08-21 11:25:44 +00:00
project = models.ForeignKey(
Project, on_delete=models.CASCADE, related_name="versions"
)
2022-08-19 10:35:05 +00:00
slug = models.SlugField(max_length=255)
name = models.CharField(max_length=255)
2022-08-20 03:33:23 +00:00
def __str__(self) -> str:
return f"{self.project} {self.slug}"
2022-08-19 10:35:05 +00:00
2022-08-20 03:33:23 +00:00
# Example: Actors
class Category(models.Model):
2022-08-19 10:35:05 +00:00
id = models.AutoField(primary_key=True)
created_on = models.DateTimeField(auto_now_add=True)
last_updated = models.DateTimeField(auto_now=True)
version = models.ForeignKey(Version, on_delete=models.CASCADE)
2022-08-20 03:33:23 +00:00
slug = models.SlugField(max_length=255)
name = models.CharField(max_length=255)
class Meta:
verbose_name_plural = "Categories"
def __str__(self) -> str:
return f"{self.version} {self.slug}"
# A snapshot in time of progress, tied to a Category
class Entry(models.Model):
id = models.AutoField(primary_key=True)
created_on = models.DateTimeField(auto_now_add=True)
last_updated = models.DateTimeField(auto_now=True)
category = models.ForeignKey(Category, on_delete=models.CASCADE)
2022-08-19 10:35:05 +00:00
timestamp = models.DateTimeField()
git_hash = models.CharField(max_length=40)
2022-08-20 03:33:23 +00:00
# Functions / files / whatever you want
total_chunks = models.IntegerField()
decompiled_chunks = models.IntegerField()
matching_chunks = models.IntegerField()
2022-08-19 10:35:05 +00:00
# Bytes
total_bytes = models.IntegerField()
decompiled_bytes = models.IntegerField()
matching_bytes = models.IntegerField()
class Meta:
2022-08-20 03:33:23 +00:00
verbose_name_plural = "Entries"
2022-08-19 10:35:05 +00:00
ordering = ["-timestamp"]
2022-08-20 03:33:23 +00:00
def __str__(self) -> str:
return f"{self.category} {self.timestamp}"