Commit b97ae158 authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Minor refactoring of the datamodel.

parent 369779fa
......@@ -85,7 +85,7 @@ def add_upload(upload: datamodel.Upload, meta_data: dict = {}) -> int:
logger = utils.get_logger(
result = None
......@@ -66,14 +66,14 @@ class Calc(Entity):
class Upload(Entity):
upload_uuid(str): The unique random id that each upload has
upload_id(str): The unique random id that each upload has
upload_hash(str): The hash/checksum that describes unique uploads
upload_time(datatime): The upload time
uploader(repo.User): The user that uploaded this upload
calcs(Iterable[Calc]): An iterable over the calculations of this upload
def upload_uuid(self) -> str:
def upload_id(self) -> str:
return '<not assigned>'
......@@ -352,10 +352,6 @@ class Upload(Chord, datamodel.Upload):
""" Returns all uploads for the given user. Currently returns all uploads. """
return cls.objects(user_id=str(user.user_id), in_staging=True)
def upload_uuid(self):
return self.upload_id
def uploader(self):
return coe_repo.User.from_user_id(self.user_id)
......@@ -45,17 +45,17 @@ class AlreadyExists(Exception): pass
class RepoUpload(datamodel.Entity):
def __init__(self, upload_uuid, upload_hash):
self.upload_uuid = upload_uuid
def __init__(self, upload_id, upload_hash):
self.upload_id = upload_id
self.upload_hash = upload_hash
def create_from(cls, obj):
return RepoUpload(obj.upload_uuid, obj.upload_hash)
return RepoUpload(obj.upload_id, obj.upload_hash)
def calcs(self):
return RepoCalc.upload_calcs(self.upload_uuid)
return RepoCalc.upload_calcs(self.upload_id)
class RepoCalc(ElasticDocument, datamodel.Entity):
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment