Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [2.5.2 - 2022-06-02](https://github.com/braincube-io/python-connector/compare/2.5.1...2.5.2)

### FIXED
Comment thread
AlexisTres marked this conversation as resolved.

- #[29](https://github.com/braincube-io/python-connector/issues/29): Fix `{get_data}` very slow when using `{label_type="name"}`

## [2.5.1 - 2021-10-25](https://github.com/braincube-io/python-connector/compare/2.5.0...2.5.1)

### FIXED
Expand Down
5 changes: 4 additions & 1 deletion braincube_connector/memory_base/memory_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ def get_data(
datasource = data.collect_data(int_var_ids, self, filters)

if label_type == "name":
mapping = {var_id: self.get_variable(var_id).get_name() for var_id in int_var_ids}
mapping = {
int(collected_variable.get_bcid()): collected_variable.get_name()
for collected_variable in self.get_variable_list()
}
datasource = {
mapping[data_key]: data_value for data_key, data_value in datasource.items()
}
Expand Down
9 changes: 5 additions & 4 deletions tests/test_memory_base/test_memory_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,11 @@ def test_get_rule_list(mocker, monkeypatch, mb_obj, mock_request_entity):
)
def test_get_data(mocker, mb_obj, create_mock_var, label_type, dataframe, expected_data):
mocker.patch(
"braincube_connector.memory_base.memory_base.MemoryBase.get_variable",
lambda memory_base_object, bcid: create_mock_var(
bcid=bcid, metadata={"standard": "name_standard_{0}".format(bcid)}
),
"braincube_connector.memory_base.memory_base.MemoryBase.get_variable_list",
return_value=[
create_mock_var(bcid=1, metadata={"standard": "name_standard_1"}),
create_mock_var(bcid=2, metadata={"standard": "name_standard_2"}),
],
)

mocker.patch(
Expand Down
18 changes: 18 additions & 0 deletions tests_integration/mocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,24 @@
"status": 200,
"json": {"name": "mb1", "order": "mb1/d101",},
},
{
"method": "GET",
"url": "https://api.test.com/braincube/demo/braincube/mb/1/variables/summary?offset=0&size=150",
"status": 200,
"json": {
"items": [
{"bcId": 101, "tag": "tag_101", "local": "local_101", "standard": "standard_101",},
{"bcId": 102, "tag": "tag_102", "local": "local_102", "standard": "standard_102",},
{"bcId": 103, "tag": "tag_103", "local": "local_103", "standard": "standard_103",},
]
},
},
{
"method": "GET",
"url": "https://api.test.com/braincube/demo/braincube/mb/1/variables/summary?offset=150&size=150",
"status": 200,
"json": {"items": []},
},
{
"method": "POST",
"url": "https://api.test.com/braincube/demo/braindata/mb1/LF",
Expand Down