diff options
| author | cedricnjanga | 2018-02-11 21:16:07 -0800 |
|---|---|---|
| committer | Zog | 2018-02-13 08:55:46 +0100 |
| commit | 6b9dd49ee49bcd43626ed507549fa0b8a71cc366 (patch) | |
| tree | 23691cd66a34aa5d28bca671d59aeb0b20f28908 | |
| parent | 7e7371087b61aaf8a128d5f5f5ec6c43c06fd4ca (diff) | |
| download | chouette-core-6b9dd49ee49bcd43626ed507549fa0b8a71cc366.tar.bz2 | |
Refs #5707 update the global status method to avoid unacessary db requests
| -rw-r--r-- | app/controllers/statuses_controller.rb | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/app/controllers/statuses_controller.rb b/app/controllers/statuses_controller.rb index 81e668ad4..e3a236e81 100644 --- a/app/controllers/statuses_controller.rb +++ b/app/controllers/statuses_controller.rb @@ -1,6 +1,6 @@ class StatusesController < ChouetteController respond_to :json - + def index status = { @@ -9,13 +9,12 @@ class StatusesController < ChouetteController imports_blocked: Import.blocked.count, compliance_check_sets_blocked: ComplianceCheckSet.blocked.count } - render json: status.to_json + render json: status.to_json end - private + private def global_status - blocked_items = Referential.blocked.count + Import.blocked.count + ComplianceCheckSet.blocked.count - blocked_items > 0 ? 'ko' : 'ok' + blocked_items = Referential.blocked.exists? || Import.blocked.exists? || ComplianceCheckSet.blocked.exists? ? 'ko' : 'ok' end -end
\ No newline at end of file +end |
