Commit 377e54d7 authored by Marc Duez's avatar Marc Duez

server : change fields from date to datetime type for results_file/fused_file/analysis_file table

-old data have been converted
-warning: don't use old backup ( <2014-09-22) on current db
parent 01b11081
......@@ -9,7 +9,7 @@
## - call exposes all registered services (none by default)
#########################################################################
import gluon.contrib.simplejson
import gluon.contrib.simplejson, time, datetime
if request.env.http_origin:
response.headers['Access-Control-Allow-Origin'] = request.env.http_origin
response.headers['Access-Control-Allow-Credentials'] = 'true'
......@@ -191,14 +191,19 @@ def save_analysis():
f = request.vars['fileToUpload']
ts = time.time()
if not analysis_query.isempty() :
analysis_id = analysis_query.select().first().id
db.analysis_file[analysis_id] = dict(analysis_file = db.analysis_file.analysis_file.store(f.file, f.filename))
else:
db.analysis_file[analysis_id] = dict(analysis_file = db.analysis_file.analysis_file.store(f.file, f.filename),
analyze_date = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
)
else:
analysis_id = db.analysis_file.insert(analysis_file = db.analysis_file.analysis_file.store(f.file, f.filename),
config_id = request.vars['config_id'],
patient_id = request.vars['patient_id'],
)
config_id = request.vars['config_id'],
patient_id = request.vars['patient_id'],
analyze_date = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
)
patient_name = db.patient[request.vars['patient_id']].first_name + " " + db.patient[request.vars['patient_id']].last_name
......
......@@ -128,21 +128,21 @@ db.define_table('config',
db.define_table('results_file',
Field('sequence_file_id', 'reference sequence_file'),
Field('config_id', 'reference config'),
Field('run_date','date'),
Field('run_date','datetime'),
Field('scheduler_task_id', 'integer'),
Field('data_file', 'upload', length=1000000000000, autodelete=True))
db.define_table('fused_file',
Field('patient_id', 'reference patient'),
Field('config_id', 'reference config'),
Field('fuse_date','date'),
Field('fuse_date','datetime'),
Field('status', 'string'),
Field('fused_file', 'upload', length=1000000000000, autodelete=True))
db.define_table('analysis_file',
Field('patient_id', 'reference patient'),
Field('config_id', 'reference config'),
Field('analyze_date','date'),
Field('analyze_date','datetime'),
Field('status', 'string'),
Field('analysis_file', 'upload', length=1000000000000, autodelete=True))
......
......@@ -97,7 +97,7 @@ def run_vidjil(id_file, id_config, id_data, id_fuse):
ts = time.time()
db.results_file[id_data] = dict(status = "ready",
run_date = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d'),
run_date = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S'),
data_file = stream
)
......@@ -123,7 +123,9 @@ def run_vidjil(id_file, id_config, id_data, id_fuse):
fuse_filepath = os.path.abspath(output_file)
stream = open(fuse_filepath, 'rb')
db.fused_file[id_fuse] = dict(fuse_date = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d'),
ts = time.time()
db.fused_file[id_fuse] = dict(fuse_date = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S'),
fused_file = stream)
db.commit()
......
Markdown is supported
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