FEATURE: Show the number of results after running a query (limit 250)

This commit is contained in:
Rishabh Nambiar 2018-09-16 21:58:16 +05:30
parent 68059b540e
commit 316923f190
4 changed files with 20 additions and 2 deletions

View File

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

View File

@ -4,6 +4,7 @@
</div>
<div class="result-about">
{{resultCount}}
{{duration}}
</div>

View File

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

View File

@ -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,
}