FEATURE: Show the number of results after running a query (limit 250)
This commit is contained in:
parent
68059b540e
commit
316923f190
|
@ -1,6 +1,7 @@
|
||||||
import { ajax } from 'discourse/lib/ajax';
|
import { ajax } from 'discourse/lib/ajax';
|
||||||
import Badge from 'discourse/models/badge';
|
import Badge from 'discourse/models/badge';
|
||||||
import { getOwner } from 'discourse-common/lib/get-owner';
|
import { getOwner } from 'discourse-common/lib/get-owner';
|
||||||
|
import { default as computed } from 'ember-addons/ember-computed-decorators';
|
||||||
|
|
||||||
function randomIdShort() {
|
function randomIdShort() {
|
||||||
return 'xxxxxxxx'.replace(/[xy]/g, function() {
|
return 'xxxxxxxx'.replace(/[xy]/g, function() {
|
||||||
|
@ -29,8 +30,17 @@ const QueryResultComponent = Ember.Component.extend({
|
||||||
columns: Em.computed.alias('content.columns'),
|
columns: Em.computed.alias('content.columns'),
|
||||||
params: Em.computed.alias('content.params'),
|
params: Em.computed.alias('content.params'),
|
||||||
explainText: Em.computed.alias('content.explain'),
|
explainText: Em.computed.alias('content.explain'),
|
||||||
|
|
||||||
hasExplain: Em.computed.notEmpty('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() {
|
colCount: function() {
|
||||||
return this.get('content.columns').length;
|
return this.get('content.columns').length;
|
||||||
}.property('content.columns.length'),
|
}.property('content.columns.length'),
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="result-about">
|
<div class="result-about">
|
||||||
|
{{resultCount}}
|
||||||
{{duration}}
|
{{duration}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,12 @@ en:
|
||||||
download_csv: "CSV"
|
download_csv: "CSV"
|
||||||
others_dirty: "A query has unsaved changes that will be lost if you navigate away."
|
others_dirty: "A query has unsaved changes that will be lost if you navigate away."
|
||||||
run_time: "Query completed in {{value}} ms."
|
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_name: "Query"
|
||||||
query_description: "Description"
|
query_description: "Description"
|
||||||
query_time: "Last run"
|
query_time: "Last run"
|
||||||
|
|
|
@ -939,7 +939,7 @@ SQL
|
||||||
|
|
||||||
def create
|
def create
|
||||||
# guardian.ensure_can_create_explorer_query!
|
# guardian.ensure_can_create_explorer_query!
|
||||||
|
|
||||||
query = DataExplorer::Query.from_hash params.require(:query)
|
query = DataExplorer::Query.from_hash params.require(:query)
|
||||||
query.created_at = Time.now
|
query.created_at = Time.now
|
||||||
query.created_by = current_user.id.to_s
|
query.created_by = current_user.id.to_s
|
||||||
|
@ -1050,6 +1050,7 @@ SQL
|
||||||
success: true,
|
success: true,
|
||||||
errors: [],
|
errors: [],
|
||||||
duration: (result[:duration_secs].to_f * 1000).round(1),
|
duration: (result[:duration_secs].to_f * 1000).round(1),
|
||||||
|
result_count: pg_result.values.length || 0,
|
||||||
params: query_params,
|
params: query_params,
|
||||||
columns: cols,
|
columns: cols,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue