Instead, the code should check the Forecast model key ('forecast_model', 'time_zero', 'issue_date') and fail only if there's a conflict. A complication: This check must be done in the database instead of the web worker due to possible timing issues. (The database determines the issue_date upon creation, which may be different from what might be calculated in the web worker. Consider the midnight problem, for example.) Thus, we must first try to create the candidate Forecast in the web worker and, if successful, pass the new forecast's ID to the worker.
Instead, the code should check the Forecast model key
('forecast_model', 'time_zero', 'issue_date')
and fail only if there's a conflict. A complication: This check must be done in the database instead of the web worker due to possible timing issues. (The database determines the issue_date upon creation, which may be different from what might be calculated in the web worker. Consider the midnight problem, for example.) Thus, we must first try to create the candidate Forecast in the web worker and, if successful, pass the new forecast's ID to the worker.