Closed filmkorn closed 1 year ago
As a workaround I changed a few lines in these inherited Variable and ApiClient classes:
class MyVariable(Variable):
"""A variable that performs an optimized request."""
def get_values(self, numofvals="ALL"):
endpoint = 'variables/' + self.id + '/values'
kwargs = {}
if isinstance(numofvals, int):
kwargs["params"] = {"page_size": str(numofvals)}
response = self.bridge.get(endpoint, **kwargs).json()
pag = Paginator(self.bridge, response, self.get_transform_function(), endpoint)
return InfoList(pag, numofvals)
class MyApiClient(ApiClient):
"""ApiClient that uses MyVariable."""
def get_variable(self, var_id, **kwargs):
raw_variable = self.bridge.get('variables/' + str(var_id), **kwargs).json()
return MyVariable(raw_variable, self.bridge)
In my test this appears to reduce the result payload to requested numofvals
.
Closed in #21
Hello,
I've been testing ubidots for a small project and ran into the following issue:
When I just need the latest value of a Variable, the ServerBridge always gets all values of the Variable. For variables with increasing number of 'dots', this increases the bandwidth needed considerably.
If I read correctly,
ServerBridge.get()
should passparams={"page_size: <number of values>"}
in here.