Skip to content
This repository has been archived by the owner on Jan 7, 2018. It is now read-only.

Commit

Permalink
Fix multiple logs.json requests being made on analytics form chagnes.
Browse files Browse the repository at this point in the history
When we introduced the query builder interface for analytics
(#7), it turns out we
accidentally started making duplicate requests for the table data.
  • Loading branch information
GUI committed Jun 26, 2015
1 parent 89ca422 commit 38cd181
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@ Admin.StatsBaseController = Ember.ObjectController.extend({

actions: {
submit: function() {
var query = this.get('query');
query.beginPropertyChanges();

if($('#filter_type_advanced').css('display') === 'none') {
this.set('query.params.search', null);
this.set('query.params.query', JSON.stringify($('#query_builder').queryBuilder('getRules')));
query.set('params.search', '');
query.set('params.query', JSON.stringify($('#query_builder').queryBuilder('getRules')));
} else {
this.set('query.params.query', null);
this.set('query.params.search', $('#filter_form input[name=search]').val());
query.set('params.query', '');
query.set('params.search', $('#filter_form input[name=search]').val());
}

query.endPropertyChanges();
},
},
});
8 changes: 7 additions & 1 deletion app/assets/javascripts/admin/views/stats/logs_table_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,13 @@ Admin.LogsTableView = Ember.View.extend({
});
},

refreshData: function() {
redrawTable: function() {
this.$().DataTable().draw();
},

refreshData: function() {
// Wrap datatables redraw in Ember.run.once so that we only trigger it once
// even if multiple query parameters are being changed at once.
Ember.run.once(this, 'redrawTable');
}.observes('controller.query.params.query', 'controller.query.params.search', 'controller.query.params.start_at', 'controller.query.params.end_at'),
});

0 comments on commit 38cd181

Please sign in to comment.