Skip to content

Commit

Permalink
Use offset numbers in the polling mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
DingoEatingFuzz committed Nov 18, 2017
1 parent 1909ab3 commit 7e41b6b
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions ui/app/utils/classes/poll-logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,18 @@ export default EmberObject.extend({
},

poll: task(function*() {
const { interval, logFetch, fullUrl } = this.getProperties('interval', 'logFetch', 'fullUrl');
const { interval, logFetch } = this.getProperties('interval', 'logFetch');
while (true) {
let text = yield logFetch(fullUrl).then(res => res.text());
let text = yield logFetch(this.get('fullUrl')).then(res => res.text());

const lines = text.replace(/\}\{/g, '}\n{').split('\n');
const frames = lines.map(line => JSON.parse(line));
frames.forEach(frame => (frame.Data = window.atob(frame.Data)));
if (text) {
const lines = text.replace(/\}\{/g, '}\n{').split('\n');
const frames = lines.map(line => JSON.parse(line));
frames.forEach(frame => (frame.Data = window.atob(frame.Data)));

this.set('endOffset', frames[frames.length - 1].Offset);
this.get('write')(frames.mapBy('Data').join(''));
this.set('endOffset', frames[frames.length - 1].Offset);
this.get('write')(frames.mapBy('Data').join(''));
}

yield timeout(interval);
}
Expand Down

0 comments on commit 7e41b6b

Please sign in to comment.