Merging in code to improve performance of calculating percent complete for a study.
Assureing we have a primary investigator for the front page (another merge)
If there is a default value, use it, regardless of whether the form is hidden (this is how the front end works)
(accomplished by moving the hide_epxression check -> continue stuff below the set default_value code)
Do an aboutface on saying that if a field is required but hidden, it has to have a default value. I'm just commenting this out for now, as it made getting these workflows to validate bloody impossible.
Clean up the replication of code for identifying required fields (as it wasn't consistently applied)
Removing some very broken and apparently unused methods.
1. Avoid ever re-generating the list of scripts that can be used in a script task. Terribly expensive as we call eval constantly, and it never ever changes once the app starts. (see script.py changes, and comments)
2. Cache the DocumentStatus list in the flask session, so we calculate it at most once per API Call. It's at least .25 seconds per call. (see study_sevice)
3. We called UserFileService.get_files_for_study (which runs a db query EVERY time) for every possible document type. Now we run the query once (study service line 321)
4. When returning a workflow, we looped through every single task in that workflow's navigation, and called the expensive spiff_task_to_api_task just to figure out it's proper display name. We run a much faster and more efficient method to calculate the display name naow (see workflow_service on lie 680, and 799)
5. A hellton of @timeit and sincetime() calls, that I want to leave in, to help debug any slowness on production.
the backend shouldn't try to set a dynamic default value. Instead, the frontend will initialize it to an empty string, then evaluate a default value, then choose to set it. (Basically, move this function from the backend and put the burden on formly)
it can be kind of irritating for this stuff to be spinning up when you are trying to debug something, so just set
PROCESS_WAITING_TASKS to false in instance/config.py and voila!!