Skip to content

Commit

Permalink
better index caluclation, while keeping performance improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
kaikoehn committed Nov 17, 2016
1 parent e9b2011 commit 6aab1c6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
12 changes: 12 additions & 0 deletions app/controllers/historical.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import Ember from 'ember';

import _ from 'lodash/lodash';


export default Ember.Controller.extend({

columns: [{
Expand Down Expand Up @@ -37,6 +40,15 @@ export default Ember.Controller.extend({
historyLogsSortingDescById : ['ts:desc'],
sortedHistoryLogsById: Ember.computed.sort('model', 'historyLogsSortingDescById'),

needsReload: Ember.computed("model.[]", function() {
let history = this.get("model")
let offerIds = history.map( x=>x.get("offerId") )
console.log("checking....")
console.log(sessionStorage["allObjIds"])
console.log(JSON.stringify( _.uniq(offerIds).sort()))
return sessionStorage["allObjIds"] !== JSON.stringify( _.uniq(offerIds).sort() )
}),

actions: {

exportCSV(historyLogs) {
Expand Down
9 changes: 7 additions & 2 deletions app/templates/historical.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@


<span class="title-container">
<h4>Historical Offers
<button type="button" class="btn btn-primary btn-xs" {{action 'exportCSV' sortedHistoryLogsById}}>Export CSV</button>
<h4>Historical Offers
{{#if needsReload}}
<p>Please reload page, so indexes can be calculated consistently</p>
{{else}}
<button type="button" class="btn btn-primary btn-xs" {{action 'exportCSV' sortedHistoryLogsById}}>Export CSV</button>
{{/if}}

</h4>
</span>

Expand Down

0 comments on commit 6aab1c6

Please sign in to comment.