1
0
mirror of https://github.com/beestat/app.git synced 2026-03-28 04:17:59 -04:00

Fixed rate limit errors

This commit is contained in:
Jon Ziebell 2026-03-26 08:28:24 -04:00
parent 653871fcb3
commit fc4c69f213
2 changed files with 81 additions and 68 deletions

View File

@ -4,10 +4,11 @@
* @param {number} thermostat_id The thermostat_id this card is displaying
* data for.
*/
beestat.component.card.comparison_settings = function(thermostat_id) {
var self = this;
this.thermostat_id_ = thermostat_id;
beestat.component.card.comparison_settings = function(thermostat_id) {
var self = this;
this.thermostat_id_ = thermostat_id;
this.get_data_in_flight_ = false;
/*
* If the thermostat changes that means the property_type could change and
@ -89,31 +90,36 @@ beestat.component.card.comparison_settings.prototype.decorate_contents_ = functi
api.send();
}, 10000);
} else {
if (thermostat.profile === null) {
this.show_loading_('Fetching');
new beestat.api()
.add_call(
'thermostat',
'generate_profile',
{
'thermostat_id': this.thermostat_id_
}
)
.add_call(
'thermostat',
'read_id',
{
'attributes': {
'inactive': 0
}
},
'thermostat'
)
.set_callback(function(response) {
beestat.cache.set('thermostat', response.thermostat);
})
.send();
} else if (beestat.cache.data.metrics === undefined) {
if (thermostat.profile === null) {
this.show_loading_('Fetching');
if (this.get_data_in_flight_ === false) {
this.get_data_in_flight_ = true;
new beestat.api()
.add_call(
'thermostat',
'generate_profile',
{
'thermostat_id': this.thermostat_id_
}
)
.add_call(
'thermostat',
'read_id',
{
'attributes': {
'inactive': 0
}
},
'thermostat'
)
.set_callback(function(response) {
this.get_data_in_flight_ = false;
beestat.cache.set('thermostat', response.thermostat);
}.bind(this))
.send();
}
} else if (beestat.cache.data.metrics === undefined) {
this.show_loading_('Fetching');
new beestat.api()
.add_call(

View File

@ -4,8 +4,9 @@
* @param {number} thermostat_id The thermostat_id this card is displaying
* data for.
*/
beestat.component.card.temperature_profiles = function(thermostat_id) {
this.thermostat_id_ = thermostat_id;
beestat.component.card.temperature_profiles = function(thermostat_id) {
this.thermostat_id_ = thermostat_id;
this.get_data_in_flight_ = false;
var self = this;
@ -47,7 +48,7 @@ beestat.component.card.temperature_profiles.prototype.decorate_subtitle_ = funct
*
* @param {rocket.Elements} parent
*/
beestat.component.card.temperature_profiles.prototype.decorate_contents_ = function(parent) {
beestat.component.card.temperature_profiles.prototype.decorate_contents_ = function(parent) {
var container = $.createElement('div').style({
'position': 'relative'
});
@ -58,7 +59,7 @@ beestat.component.card.temperature_profiles.prototype.decorate_contents_ = funct
var chart_container = $.createElement('div');
container.appendChild(chart_container);
if (this.has_data_() === false) {
if (this.has_data_() === false) {
chart_container.style('filter', 'blur(3px)');
var no_data = $.createElement('div');
no_data.style({
@ -182,37 +183,43 @@ beestat.component.card.temperature_profiles.prototype.get_data_ = function() {
var profiles = this.get_profiles_();
var is_current = (this.profile_index_ === undefined || this.profile_index_ === profiles.length - 1);
if (
is_current &&
(
selected_profile === null ||
moment().diff(moment(selected_profile.metadata.generated_at), 'days') >= 7
)
) {
this.show_loading_('Fetching');
new beestat.api()
.add_call(
'thermostat',
'generate_profile',
{
'thermostat_id': this.thermostat_id_
}
)
.add_call(
'thermostat',
'read_id',
{
'attributes': {
'inactive': 0
}
},
'thermostat'
)
.set_callback(function(response) {
beestat.cache.set('thermostat', response.thermostat);
})
.send();
} else if (selected_profile !== null) {
if (
is_current &&
(
selected_profile === null ||
moment().diff(moment(selected_profile.metadata.generated_at), 'days') >= 7
)
) {
this.show_loading_('Fetching');
if (this.get_data_in_flight_ === false) {
this.get_data_in_flight_ = true;
new beestat.api()
.add_call(
'thermostat',
'generate_profile',
{
'thermostat_id': this.thermostat_id_
}
)
.add_call(
'thermostat',
'read_id',
{
'attributes': {
'inactive': 0
}
},
'thermostat'
)
.set_callback(function(response) {
this.get_data_in_flight_ = false;
beestat.cache.set('thermostat', response.thermostat);
}.bind(this))
.send();
}
} else if (selected_profile !== null) {
const profile_extremes = this.get_profile_extremes_(5);
var y_min = Infinity;
@ -552,7 +559,7 @@ beestat.component.card.temperature_profiles.prototype.get_selected_profile_ = fu
*
* @return {boolean}
*/
beestat.component.card.temperature_profiles.prototype.has_data_ = function() {
const data = this.get_data_();
return Object.keys(data.series).length > 0;
};
beestat.component.card.temperature_profiles.prototype.has_data_ = function() {
const data = this.get_data_();
return Object.keys(data.series).length > 0;
};