db changes
This commit is contained in:
parent
f9ab6ffbf9
commit
800996542f
|
@ -2,4 +2,5 @@ __pycache__
|
||||||
*.pyc
|
*.pyc
|
||||||
*.db
|
*.db
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.env.*
|
.env.*
|
||||||
|
db.sqlite3
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
from frog_api.models import Project
|
from frog_api.models import Category, Entry, Project, Version
|
||||||
|
|
||||||
admin.site.register(Project)
|
admin.site.register(Project)
|
||||||
|
admin.site.register(Version)
|
||||||
|
admin.site.register(Category)
|
||||||
|
admin.site.register(Entry)
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
# Generated by Django 4.1 on 2022-08-20 02:04
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("frog_api", "0001_initial"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name="entry",
|
||||||
|
name="version",
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name="Category",
|
||||||
|
fields=[
|
||||||
|
("id", models.AutoField(primary_key=True, serialize=False)),
|
||||||
|
("created_on", models.DateTimeField(auto_now_add=True)),
|
||||||
|
("last_updated", models.DateTimeField(auto_now=True)),
|
||||||
|
("slug", models.SlugField(max_length=255)),
|
||||||
|
("name", models.CharField(max_length=255)),
|
||||||
|
(
|
||||||
|
"version",
|
||||||
|
models.ForeignKey(
|
||||||
|
on_delete=django.db.models.deletion.CASCADE,
|
||||||
|
to="frog_api.version",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="entry",
|
||||||
|
name="category",
|
||||||
|
field=models.ForeignKey(
|
||||||
|
default="",
|
||||||
|
on_delete=django.db.models.deletion.CASCADE,
|
||||||
|
to="frog_api.category",
|
||||||
|
),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
]
|
|
@ -0,0 +1,32 @@
|
||||||
|
# Generated by Django 4.1 on 2022-08-20 02:19
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("frog_api", "0002_remove_entry_version_category_entry_category"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name="entry",
|
||||||
|
old_name="decompiled_functions",
|
||||||
|
new_name="decompiled_chunks",
|
||||||
|
),
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name="entry",
|
||||||
|
old_name="matching_functions",
|
||||||
|
new_name="matching_chunks",
|
||||||
|
),
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name="entry",
|
||||||
|
old_name="total_functions",
|
||||||
|
new_name="total_chunks",
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name="entry",
|
||||||
|
name="other_data",
|
||||||
|
),
|
||||||
|
]
|
|
@ -1,6 +1,6 @@
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
|
# Example: OOT
|
||||||
class Project(models.Model):
|
class Project(models.Model):
|
||||||
id = models.AutoField(primary_key=True)
|
id = models.AutoField(primary_key=True)
|
||||||
created_on = models.DateTimeField(auto_now_add=True)
|
created_on = models.DateTimeField(auto_now_add=True)
|
||||||
|
@ -10,7 +10,11 @@ class Project(models.Model):
|
||||||
name = models.CharField(max_length=255)
|
name = models.CharField(max_length=255)
|
||||||
auth_key = models.CharField(max_length=255)
|
auth_key = models.CharField(max_length=255)
|
||||||
|
|
||||||
|
def __str__(self) -> str:
|
||||||
|
return self.slug
|
||||||
|
|
||||||
|
|
||||||
|
# Example: US 1.0
|
||||||
class Version(models.Model):
|
class Version(models.Model):
|
||||||
id = models.AutoField(primary_key=True)
|
id = models.AutoField(primary_key=True)
|
||||||
created_on = models.DateTimeField(auto_now_add=True)
|
created_on = models.DateTimeField(auto_now_add=True)
|
||||||
|
@ -20,25 +24,48 @@ class Version(models.Model):
|
||||||
slug = models.SlugField(max_length=255)
|
slug = models.SlugField(max_length=255)
|
||||||
name = models.CharField(max_length=255)
|
name = models.CharField(max_length=255)
|
||||||
|
|
||||||
|
def __str__(self) -> str:
|
||||||
|
return f"{self.project} {self.slug}"
|
||||||
|
|
||||||
class Entry(models.Model):
|
|
||||||
|
# Example: Actors
|
||||||
|
class Category(models.Model):
|
||||||
id = models.AutoField(primary_key=True)
|
id = models.AutoField(primary_key=True)
|
||||||
created_on = models.DateTimeField(auto_now_add=True)
|
created_on = models.DateTimeField(auto_now_add=True)
|
||||||
last_updated = models.DateTimeField(auto_now=True)
|
last_updated = models.DateTimeField(auto_now=True)
|
||||||
|
|
||||||
version = models.ForeignKey(Version, on_delete=models.CASCADE)
|
version = models.ForeignKey(Version, on_delete=models.CASCADE)
|
||||||
|
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)
|
||||||
timestamp = models.DateTimeField()
|
timestamp = models.DateTimeField()
|
||||||
git_hash = models.CharField(max_length=40)
|
git_hash = models.CharField(max_length=40)
|
||||||
# Functions
|
# Functions / files / whatever you want
|
||||||
total_functions = models.IntegerField()
|
total_chunks = models.IntegerField()
|
||||||
decompiled_functions = models.IntegerField()
|
decompiled_chunks = models.IntegerField()
|
||||||
matching_functions = models.IntegerField()
|
matching_chunks = models.IntegerField()
|
||||||
# Bytes
|
# Bytes
|
||||||
total_bytes = models.IntegerField()
|
total_bytes = models.IntegerField()
|
||||||
decompiled_bytes = models.IntegerField()
|
decompiled_bytes = models.IntegerField()
|
||||||
matching_bytes = models.IntegerField()
|
matching_bytes = models.IntegerField()
|
||||||
# Other
|
|
||||||
other_data = models.JSONField(null=True, blank=True)
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
verbose_name_plural = "Entries"
|
||||||
ordering = ["-timestamp"]
|
ordering = ["-timestamp"]
|
||||||
|
|
||||||
|
def __str__(self) -> str:
|
||||||
|
return f"{self.category} {self.timestamp}"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
||||||
from frog_api.models import Project, Version
|
from frog_api.models import Entry, Project, Version
|
||||||
|
|
||||||
|
|
||||||
class ProjectSerializer(serializers.HyperlinkedModelSerializer):
|
class ProjectSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
@ -17,16 +17,14 @@ class VersionSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
|
||||||
class EntrySerializer(serializers.HyperlinkedModelSerializer):
|
class EntrySerializer(serializers.HyperlinkedModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Version
|
model = Entry
|
||||||
fields = [
|
fields = [
|
||||||
"version",
|
|
||||||
"timestamp",
|
"timestamp",
|
||||||
"git_hash",
|
"git_hash",
|
||||||
"total_functions",
|
"total_chunks",
|
||||||
"decompiled_functions",
|
"decompiled_chunks",
|
||||||
"matching_functions",
|
"matching_chunks",
|
||||||
"total_bytes",
|
"total_bytes",
|
||||||
"decompiled_bytes",
|
"decompiled_bytes",
|
||||||
"matching_bytes",
|
"matching_bytes",
|
||||||
"other_data",
|
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
|
from typing import Any
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
from rest_framework.views import APIView
|
from rest_framework.views import APIView
|
||||||
|
from rest_framework import mixins
|
||||||
|
from rest_framework.request import Request
|
||||||
|
from rest_framework.viewsets import GenericViewSet
|
||||||
|
|
||||||
from frog_api.models import Project
|
from frog_api.models import Entry, Project
|
||||||
from frog_api.serializers import ProjectSerializer
|
from frog_api.serializers import EntrySerializer, ProjectSerializer
|
||||||
|
|
||||||
|
|
||||||
class ProjectView(APIView):
|
class ProjectView(APIView):
|
||||||
|
|
Loading…
Reference in New Issue