[chronojump-server] Added resultSprint table With this new table, database is completed for this version.
- From: Marcos Venteo Garcia <mventeo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump-server] Added resultSprint table With this new table, database is completed for this version.
- Date: Sat, 24 Jun 2017 09:02:31 +0000 (UTC)
commit fac7ecb0210e34a6877e8d66083ae0667335d3b5
Author: Marcos Venteo GarcĂa <mventeo gmail com>
Date: Sat Jun 24 11:02:20 2017 +0200
Added resultSprint table
With this new table, database is completed for this version.
chronojumpserver/models.py | 52 ++++++++++++++++++++++++++++++++++++++++---
1 files changed, 48 insertions(+), 4 deletions(-)
---
diff --git a/chronojumpserver/models.py b/chronojumpserver/models.py
index ee46e5d..649e331 100755
--- a/chronojumpserver/models.py
+++ b/chronojumpserver/models.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from chronojumpserver.database import Base, db_session
from datetime import datetime
-from sqlalchemy import Column, Integer, String, Float, Date, Enum, ForeignKey, UniqueConstraint
+from sqlalchemy import Column, Integer, String, Float, DateTime, Enum, ForeignKey, UniqueConstraint
from sqlalchemy.types import Boolean, Enum
from sqlalchemy.orm import relationship
@@ -170,7 +170,7 @@ class Task(Base):
__tablename__ = "task"
id = Column(Integer, primary_key=True)
taskType = Column(String(1)) # F - Free, P - Parametrized
- ts = Column(Date)
+ ts = Column(DateTime, default=datetime.utcnow)
personId = Column('personId', ForeignKey('person.id'))
person = relationship(Person, primaryjoin=personId == Person.id)
stationId = Column('stationId', ForeignKey('station.id'))
@@ -190,7 +190,7 @@ class Task(Base):
personId=None,
exerciseId=None, nreps=None, sets=-1, load=None, laterality=None,
comment=None, done=False):
- """Initialize a Task object"""
+ """Initialize a Task object."""
self.taskType = taskType
self.ts = ts
self.personId = personId
@@ -250,7 +250,7 @@ class ResultEncoder(Base):
"""Result model."""
__tablename__ = 'resultEncoder'
id = Column('id', Integer, primary_key=True)
- dt = Column('dt', Date)
+ dt = Column('dt', DateTime, default=datetime.now)
personId = Column('personId', ForeignKey('person.id'))
person = relationship(Person, primaryjoin=personId == Person.id)
stationId = Column('stationId', ForeignKey('station.id'))
@@ -341,3 +341,47 @@ class ResultEncoder(Base):
def __repr__(self):
"""Representation od the object."""
return '<Result %d>' % (self.id)
+
+class ResultSprint(Base):
+ __tablename__ = 'resultSprint'
+ id = Column('id', Integer, primary_key=True)
+ dt = Column('dt', DateTime, default=datetime.now)
+ personId = Column('personId', ForeignKey('person.id'))
+ person = relationship(Person, primaryjoin=personId == Person.id)
+ distances = Column(String(50))
+ times = Column(String(50))
+ k = Column(Float)
+ vmax = Column(Float)
+ amax = Column(Float)
+ fmax = Column(Float)
+ pmax = Column(Float)
+
+ def __init__(self, dt=None, personId=None, distances=None, times=None,
+ k=None, vmax=None, amax=None, fmax=None, pmax=None):
+ """Object initialization."""
+ self.dt = dt if dt is not None else datetime.now()
+ # Rest of values will be assigned directly from params
+ self.personId = personId
+ self.distances = distances
+ self.times = times
+ self.k = k
+ self.vmax = vmax
+ self.amax = amax
+ self.fmax = fmax
+ self.pmax = pmax
+
+ def serialize(self):
+ """Object serialization (Json)."""
+ return {
+ 'id' : self.id,
+ 'dt' : self.dt,
+ 'personId': self.personId,
+ 'personName': self.person.name,
+ 'distances' : self.distances,
+ 'times' : self.times,
+ 'k' : self.k,
+ 'vmax' : self.vmax,
+ 'amax' : self.amax,
+ 'fmax' : self.fmax,
+ 'pmax' : self.pmax
+ }
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]