DEV: Replace hardcoded result limit with a module constant

This commit is contained in:
Rishabh 2019-01-21 14:21:53 +05:30
parent f1b33cc64e
commit 8720c2cd5c
2 changed files with 5 additions and 2 deletions

View File

@ -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 });

View File

@ -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)