diff --git a/assets/javascripts/discourse/components/query-result.js.es6 b/assets/javascripts/discourse/components/query-result.js.es6 index 772adbb..0ad5a26 100644 --- a/assets/javascripts/discourse/components/query-result.js.es6 +++ b/assets/javascripts/discourse/components/query-result.js.es6 @@ -1,6 +1,7 @@ import { ajax } from 'discourse/lib/ajax'; import Badge from 'discourse/models/badge'; import { getOwner } from 'discourse-common/lib/get-owner'; +import { default as computed } from 'ember-addons/ember-computed-decorators'; function randomIdShort() { return 'xxxxxxxx'.replace(/[xy]/g, function() { @@ -29,8 +30,17 @@ const QueryResultComponent = Ember.Component.extend({ columns: Em.computed.alias('content.columns'), params: Em.computed.alias('content.params'), explainText: Em.computed.alias('content.explain'), - hasExplain: Em.computed.notEmpty('content.explain'), + + @computed('content.result_count') + resultCount: function(count) { + if (count === 250) { + return I18n.t('explorer.max_result_count', { count }); + } else { + return I18n.t('explorer.result_count', { count }); + } + }, + colCount: function() { return this.get('content.columns').length; }.property('content.columns.length'), diff --git a/assets/javascripts/discourse/templates/explorer-query-result.hbs b/assets/javascripts/discourse/templates/explorer-query-result.hbs index b9f6a33..6c1e03d 100644 --- a/assets/javascripts/discourse/templates/explorer-query-result.hbs +++ b/assets/javascripts/discourse/templates/explorer-query-result.hbs @@ -4,6 +4,7 @@
+ {{resultCount}} {{duration}}
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 6f52a66..fb56b3f 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -52,6 +52,12 @@ en: download_csv: "CSV" others_dirty: "A query has unsaved changes that will be lost if you navigate away." run_time: "Query completed in {{value}} ms." + result_count: + one: "%{count} result." + other: "%{count} results." + max_result_count: + one: "Showing top %{count} results." + other: "Showing top %{count} results." query_name: "Query" query_description: "Description" query_time: "Last run" diff --git a/plugin.rb b/plugin.rb index 51f9244..5371787 100644 --- a/plugin.rb +++ b/plugin.rb @@ -939,7 +939,7 @@ SQL def create # guardian.ensure_can_create_explorer_query! - + query = DataExplorer::Query.from_hash params.require(:query) query.created_at = Time.now query.created_by = current_user.id.to_s @@ -1050,6 +1050,7 @@ SQL success: true, errors: [], duration: (result[:duration_secs].to_f * 1000).round(1), + result_count: pg_result.values.length || 0, params: query_params, columns: cols, }