Temp save to test dev
This commit is contained in:
parent
232b92b39a
commit
0d8d251e8e
|
@ -12,6 +12,7 @@ from flask_mail import Mail
|
||||||
from flask_migrate import Migrate
|
from flask_migrate import Migrate
|
||||||
from flask_sqlalchemy import SQLAlchemy
|
from flask_sqlalchemy import SQLAlchemy
|
||||||
from sentry_sdk.integrations.flask import FlaskIntegration
|
from sentry_sdk.integrations.flask import FlaskIntegration
|
||||||
|
from apscheduler.schedulers.background import BackgroundScheduler
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
|
||||||
|
@ -33,6 +34,7 @@ db = SQLAlchemy(app)
|
||||||
|
|
||||||
session = db.session
|
session = db.session
|
||||||
""":type: sqlalchemy.orm.Session"""
|
""":type: sqlalchemy.orm.Session"""
|
||||||
|
scheduler = BackgroundScheduler()
|
||||||
|
|
||||||
# Mail settings
|
# Mail settings
|
||||||
mail = Mail(app)
|
mail = Mail(app)
|
||||||
|
@ -46,6 +48,9 @@ from crc.api import admin
|
||||||
|
|
||||||
connexion_app.add_api('api.yml', base_path='/v1.0')
|
connexion_app.add_api('api.yml', base_path='/v1.0')
|
||||||
|
|
||||||
|
def setup_scheduler():
|
||||||
|
from crc.services.workflow_service import WorkflowService
|
||||||
|
scheduler.add_job(WorkflowService.do_waiting())
|
||||||
|
|
||||||
# Convert list of allowed origins to list of regexes
|
# Convert list of allowed origins to list of regexes
|
||||||
origins_re = [r"^https?:\/\/%s(.*)" % o.replace('.', '\.') for o in app.config['CORS_ALLOW_ORIGINS']]
|
origins_re = [r"^https?:\/\/%s(.*)" % o.replace('.', '\.') for o in app.config['CORS_ALLOW_ORIGINS']]
|
||||||
|
|
|
@ -364,6 +364,13 @@ class WorkflowProcessor(object):
|
||||||
def get_status(self):
|
def get_status(self):
|
||||||
return self.status_of(self.bpmn_workflow)
|
return self.status_of(self.bpmn_workflow)
|
||||||
|
|
||||||
|
def update_waiting_tasks(self):
|
||||||
|
try:
|
||||||
|
self.bpmn_workflow.refresh_waiting_tasks()
|
||||||
|
except WorkflowTaskExecException as we:
|
||||||
|
raise ApiError.from_task("task_error", str(we), we.task)
|
||||||
|
|
||||||
|
|
||||||
def do_engine_steps(self):
|
def do_engine_steps(self):
|
||||||
try:
|
try:
|
||||||
self.bpmn_workflow.do_engine_steps()
|
self.bpmn_workflow.do_engine_steps()
|
||||||
|
|
|
@ -90,6 +90,15 @@ class WorkflowService(object):
|
||||||
if user:
|
if user:
|
||||||
db.session.delete(user)
|
db.session.delete(user)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def do_waiting():
|
||||||
|
records = db.session.query(WorkflowModel).filter(WorkflowModel.status==WorkflowStatus.waiting).all()
|
||||||
|
for workflow_model in records:
|
||||||
|
processor = WorkflowProcessor(workflow_model)
|
||||||
|
processor.bpmn_workflow.update_waiting_tasks()
|
||||||
|
processor.bpmn_workflow.do_engine_steps()
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def test_spec(spec_id, validate_study_id=None, required_only=False):
|
def test_spec(spec_id, validate_study_id=None, required_only=False):
|
||||||
"""Runs a spec through it's paces to see if it results in any errors.
|
"""Runs a spec through it's paces to see if it results in any errors.
|
||||||
|
|
Loading…
Reference in New Issue