From 8720c2cd5c4898227e35e9ca944fb94e838ce220 Mon Sep 17 00:00:00 2001 From: Rishabh Date: Mon, 21 Jan 2019 14:21:53 +0530 Subject: [PATCH] DEV: Replace hardcoded result limit with a module constant --- assets/javascripts/discourse/components/query-result.js.es6 | 2 +- plugin.rb | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/assets/javascripts/discourse/components/query-result.js.es6 b/assets/javascripts/discourse/components/query-result.js.es6 index 22a22a0..72cf5c3 100644 --- a/assets/javascripts/discourse/components/query-result.js.es6 +++ b/assets/javascripts/discourse/components/query-result.js.es6 @@ -34,7 +34,7 @@ const QueryResultComponent = Ember.Component.extend({ @computed("content.result_count") resultCount: function(count) { - if (count === 1000) { + if (count === this.get("content.result_limit")) { return I18n.t("explorer.max_result_count", { count }); } else { return I18n.t("explorer.result_count", { count }); diff --git a/plugin.rb b/plugin.rb index 2b7897c..dc7df02 100644 --- a/plugin.rb +++ b/plugin.rb @@ -21,6 +21,8 @@ end add_admin_route 'explorer.title', 'explorer' module ::DataExplorer + QUERY_RESULT_MAX_LIMIT = 1000 + def self.plugin_name 'discourse-data-explorer'.freeze end @@ -109,7 +111,7 @@ after_initialize do WITH query AS ( #{query.sql} ) SELECT * FROM query -LIMIT #{opts[:limit] || 1000} +LIMIT #{opts[:limit] || DataExplorer::QUERY_RESULT_MAX_LIMIT} SQL time_start = Time.now @@ -1102,6 +1104,7 @@ SQL result_count: pg_result.values.length || 0, params: query_params, columns: cols, + result_limit: DataExplorer::QUERY_RESULT_MAX_LIMIT } json[:explain] = result[:explain] if opts[:explain] ext = DataExplorer.add_extra_data(pg_result)