Browse Source

broken, but adding whtielist

cjs3
Stephen Lorenz 3 years ago
parent
commit
e3643503a9
  1. 16
      cjsd/cjsd/core/database.py
  2. 9
      cjsd/cjsd/resources/database.py

16
cjsd/cjsd/core/database.py

@ -360,7 +360,7 @@ def non_contrib_add(name, comparison_list):
# TODO: implement fine-grained handling
raise
def stage_jobs(name, batch_name):
def stage_jobs(name, batch_name, whitelist):
# TODO: THIS NEEDS TO BE RESOLVED BETTER
# TODO: IT IS INCREDIBLY SLOW OTHERWISE
try:
@ -371,10 +371,18 @@ def stage_jobs(name, batch_name):
sess.add(batch_table)
sess.flush()
test_list = sess.query(TestTable).all()
job_list = []
for Test in test_list:
job_list.append(JobTable(Test.id_, batch_table.id_))
if whitelist:
for row in whitelist:
ename, cname = row
evidence_table = sess.query(EvidenceTable).filter(EvidenceTable.name == ename).first()
comparison_table = sess.query(ComparisonTable).filter(ComparisonTable.name == cname).first()
test_table = sess.query(TestTable).filter(TestTable.evidence_id == evidence_table.id_).filter(TestTable.comparison_id == comparison_id == comparison_table.id_).first()
job_list.append(JobTable(table_table.id_, batch_table.id_))
else:
test_list = sess.query(TestTable).all()
for Test in test_list:
job_list.append(JobTable(Test.id_, batch_table.id_))
sess.bulk_save_objects(job_list)
sess.commit()
sess.close()

9
cjsd/cjsd/resources/database.py

@ -339,6 +339,11 @@ class StageResource:
def on_post(self, req, resp):
database_name = req.context['database']
batch_name = req.context['batch']
whitelist = None
try:
whitelist = req.media['whitelist']
except:
pass
try:
# determine the existing database's location
database_path = database_location(database_name)
@ -346,11 +351,11 @@ class StageResource:
# create new batch directory
create_dir('%s/output/%s' % (database_path, batch_name))
stage_jobs(database_name, batch_name)
stage_jobs(database_name, batch_name, whitelist)
except IntegrityError:
raise falcon.HTTPBadRequest('Batch exists',
'Unable add to batch table. Try another batch name.')
except Exception as e:
raise
# END command-line interface
# END command-line interface
Loading…
Cancel
Save