Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance fixes #5134

Merged
merged 4 commits into from
Oct 22, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Sort entries once on load and then rely on the sorting to find out th…
…e largest and smallest value
  • Loading branch information
sulkaharo committed Oct 21, 2019
commit 74bfa726aa52391be61ebed2af51f59347651c2c
6 changes: 5 additions & 1 deletion lib/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ client.load = function load (serverSettings, callback) {

client.dataExtent = function dataExtent () {
if (client.entries.length > 0) {
return d3.extent(client.entries, client.entryToDate);
return[client.entryToDate(client.entries[0]), client.entryToDate(client.entries[client.entries.length-1])];
} else {
return [new Date(client.now - times.hours(history).msecs), new Date(client.now)];
}
Expand Down Expand Up @@ -1147,6 +1147,10 @@ client.load = function load (serverSettings, callback) {
point.color = 'transparent';
}
});

client.entries.sort(function sorter(a,b) {
return a.mills - b.mills;
});
}

function dataUpdate (received) {
Expand Down
2 changes: 1 addition & 1 deletion lib/profilefunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var c = require('memory-cache');
var times = require('./times');
var crypto = require('crypto');

var cacheTTL = 1000;
var cacheTTL = 5000;
var prevBasalTreatment = null;
var cache = new c.Cache();

Expand Down