|
@@ -52,16 +52,25 @@ var ApiController = function(app) {
|
|
.then(function(data) {
|
|
.then(function(data) {
|
|
|
|
|
|
debug('Success');
|
|
debug('Success');
|
|
- runsDatastore.markAsComplete(run.runId);
|
|
|
|
|
|
+
|
|
|
|
|
|
// Save result in datastore
|
|
// Save result in datastore
|
|
data.runId = run.runId;
|
|
data.runId = run.runId;
|
|
- resultsDatastore.saveResult(data);
|
|
|
|
-
|
|
|
|
- // Send result if the user was waiting
|
|
|
|
- if (run.params.waitForResponse) {
|
|
|
|
- res.redirect(302, '/api/results/' + run.runId);
|
|
|
|
- }
|
|
|
|
|
|
+ resultsDatastore.saveResult(data)
|
|
|
|
+ .then(function() {
|
|
|
|
+
|
|
|
|
+ runsDatastore.markAsComplete(run.runId);
|
|
|
|
+
|
|
|
|
+ // Send result if the user was waiting
|
|
|
|
+ if (run.params.waitForResponse) {
|
|
|
|
+ res.redirect(302, '/api/results/' + run.runId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ })
|
|
|
|
+ .fail(function(err) {
|
|
|
|
+ debug('Saving results to resultsDatastore failed:');
|
|
|
|
+ debug(err);
|
|
|
|
+ });
|
|
|
|
|
|
}).fail(function(err) {
|
|
}).fail(function(err) {
|
|
|
|
|