[chronojump-server] Creation of new tables
- From: Marcos Venteo Garcia <mventeo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump-server] Creation of new tables
- Date: Mon, 19 Feb 2018 17:58:43 +0000 (UTC)
commit 4e345a7ea95226661bd1208afb1c47f40afb6788
Author: Marcos Venteo GarcĂa <mventeo gmail com>
Date: Tue Jan 9 15:46:17 2018 +0100
Creation of new tables
.gitignore | 4 +
chronojumpserver/models.py | 51 ++++++++++++++++-
chronojumpserver/tests/populate_test_results.py | 69 +++++++++++++++++++++++
3 files changed, 123 insertions(+), 1 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index db4561e..265c921 100644
--- a/.gitignore
+++ b/.gitignore
@@ -52,3 +52,7 @@ docs/_build/
# PyBuilder
target/
+
+Dockerfile
+chronojump.conf.example
+chronojumpserver/static/images/photos/
diff --git a/chronojumpserver/models.py b/chronojumpserver/models.py
index 8397e07..99ebc78 100755
--- a/chronojumpserver/models.py
+++ b/chronojumpserver/models.py
@@ -1,11 +1,13 @@
# -*- coding: utf-8 -*-
from chronojumpserver.database import Base, db_session
from datetime import datetime
-from sqlalchemy import Column, Integer, String, Float, DateTime, ForeignKey, UniqueConstraint
+from sqlalchemy import Column, Integer, String, Float, DateTime, ForeignKey
+from sqlalchemy import UniqueConstraint
from sqlalchemy.types import Boolean
from sqlalchemy.orm import relationship
from flask_login import UserMixin
+
class HelperMixin(object):
id = Column(Integer, primary_key=True)
@@ -21,6 +23,53 @@ class HelperMixin(object):
return o
+class Organization(HelperMixin, Base):
+ __tablename__ = 'organization'
+
+ name = Column(String(50), unique=True)
+ country = Column(String(50), nullable=False)
+ responsable = Column(String(50), nullable=False)
+
+
+class Gym(HelperMixin, Base):
+ __tablename__ = 'gym'
+
+ org_id = Column(Integer, nullable=False)
+ name = Column(String(50), unique=True)
+ responsable = Column(String(50), nullable=False)
+
+
+class Group(HelperMixin, Base):
+ __tablename__ = 'group'
+
+ org_id = Column(Integer, nullable=False)
+ gym_id = Column(Integer, nullable=False)
+ name = Column(String(50), unique=True)
+ responsable = Column(String(50), nullable=False)
+
+
+class Coach(HelperMixin, Base):
+ __tablename__ = 'coach'
+
+ org_id = Column(Integer, nullable=False)
+ name = Column(String(50), unique=True)
+ details = Column(String(100), nullable=False)
+
+
+class GroupCoach(HelperMixin, Base):
+ __tablename__ = 'groupCoach'
+
+ group_id = Column(Integer, nullable=False)
+ coach_id = Column(Integer, nullable=False)
+
+
+class groupPlayer(HelperMixin, Base):
+ __tablename__ = 'groupPlayer'
+
+ group_id = Column(Integer, nullable=False)
+ player_id = Column(Integer, nullable=False)
+
+
class Person(HelperMixin, Base):
"""Person model.
diff --git a/chronojumpserver/tests/populate_test_results.py b/chronojumpserver/tests/populate_test_results.py
new file mode 100644
index 0000000..d46149c
--- /dev/null
+++ b/chronojumpserver/tests/populate_test_results.py
@@ -0,0 +1,69 @@
+from chronojumpserver.database import db_session
+from chronojumpserver.models import ResultEncoder
+import sys
+import random
+from datetime import datetime
+
+if __name__ == "__main__":
+ """
+ __tablename__ = 'resultEncoder'
+ 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)
+ stationId = Column('stationId', ForeignKey('station.id'))
+ station = relationship(Station, primaryjoin=stationId == Station.id)
+ exerciseId = Column('exerciseId', ForeignKey('exercise.id'))
+ exercise = relationship(Exercise, primaryjoin=exerciseId == Exercise.id)
+ laterality = Column('laterality', String(2))
+ resistance = Column('resistance', Float)
+ repetitions = Column('repetitions', Integer)
+ lossBySpeed = Column('lossBySpeed', Float)
+ numBySpeed = Column('numBySpeed', Integer)
+ rangeBySpeed = Column('rangeBySpeed', Float)
+ vmeanBySpeed = Column('vmeanBySpeed', Float)
+ vmaxBySpeed = Column('vmaxBySpeed', Float)
+ pmeanBySpeed = Column('pmeanBySpeed', Float)
+ pmaxBySpeed = Column('pmaxBySpeed', Float)
+ lossByPower = Column('lossByPower', Integer)
+ numByPower = Column('numByPower', Integer)
+ rangeByPower = Column('rangeByPower', Float)
+ vmeanByPower = Column('vmeanByPower', Float)
+ vmaxByPower = Column('vmaxByPower', Float)
+ pmeanByPower = Column('pmeanByPower', Float)
+ pmaxByPower = Column('pmaxByPower', Float)
+ comments = Column('comments', String(30))"""
+
+ date_given = sys.argv[1]
+ results_wanted = int(sys.argv[2])
+
+ for i in range(results_wanted):
+ r = ResultEncoder()
+ hh = random.randint(10, 20)
+ mm = random.randint(0, 59)
+ ss = random.randint(0, 59)
+ result_date = "%s %02d:%02d:%02d" % (date_given, hh, mm, ss)
+ r.dt = datetime.strptime(result_date, "%d/%m/%Y %H:%M:%S")
+ r.personId = 1
+ r.stationId = 1
+ r.exerciseId = 1
+ r.laterality = 'L'
+ r.resistance = random.uniform(10, 80)
+ r.repetitions = random.randint(1, 30)
+ r.lossBySpeed = random.uniform(10, 80)
+ r.numBySpeed = random.randint(1, 30)
+ r.rangeBySpeed = random.uniform(10, 80)
+ r.vmeanBySpeed = random.uniform(10, 80)
+ r.vmaxBySpeed = random.uniform(10, 80)
+ r.pmeanBySpeed = random.uniform(10, 80)
+ r.pmaxBySpeed = random.uniform(10, 80)
+ r.lossByPower = random.randint(1, 30)
+ r.numByPower = random.randint(1, 30)
+ r.rangeByPower = random.uniform(10, 80)
+ r.vmeanByPower = random.uniform(10, 80)
+ r.vmaxByPower = random.uniform(10, 80)
+ r.pmeanByPower = random.uniform(10, 80)
+ r.pmaxByPower = random.uniform(10, 80)
+ r.comments = "Random created automatically"
+ db_session.add(r)
+ db_session.commit()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]