Skip to content

Commit dca67b9

Browse files
authored
Merge pull request #47 from dataiku/bug/dss13-sc-207988-pi-system-end-value-and-value-data-types
Bug/dss13 sc 207988 pi system end value and value data types
2 parents a8828b4 + b6e6252 commit dca67b9

File tree

5 files changed

+35
-8
lines changed

5 files changed

+35
-8
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
## [Version 1.2.3](https://github.com/dataiku/dss-plugin-pi-server/releases/tag/v1.2.3) - Feature release - 2024-09-26
44

5-
- Add summaryDuration selector (duration of each summary interval)
5+
- Add summaryDuration input (duration of each summary interval)
66
- Fix issue when using `Starting After` search option in browse PI event frames
7+
- Fix issue with `Value` and `End value` data types in Search attributes dataset
8+
- Add pagination on element retrieval
79

810
## [Version 1.2.2](https://github.com/dataiku/dss-plugin-pi-server/releases/tag/v1.2.2) - Feature release - 2023-12-11
911

python-connectors/pi-system_attribute-search/connector.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from osisoft_plugin_common import (
77
PISystemConnectorError, RecordsLimit, get_credentials, assert_time_format,
88
remove_unwanted_columns, format_output, filter_columns_from_schema, is_child_attribute_path,
9-
check_debug_mode, PerformanceTimer, get_max_count, get_summary_parameters
9+
check_debug_mode, PerformanceTimer, get_max_count, get_summary_parameters, fields_selector
1010
)
1111
from osisoft_constants import OSIsoftConstants
1212

@@ -111,7 +111,7 @@ def generate_rows(self, dataset_schema=None, dataset_partitioning=None,
111111
interval=self.interval,
112112
sync_time=self.sync_time,
113113
endpoint_type="AF",
114-
selected_fields="Links%3BItems.Timestamp%3BItems.Value%3BItems.Type",
114+
selected_fields=fields_selector(self.data_type),
115115
max_count=self.max_count,
116116
summary_type=self.summary_type,
117117
summary_duration=self.summary_duration

python-lib/osisoft_client.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from osisoft_plugin_common import (
1111
assert_server_url_ok, build_requests_params,
1212
is_filtered_out, is_server_throttling, escape, epoch_to_iso,
13-
iso_to_epoch, RecordsLimit, is_iso8601
13+
iso_to_epoch, RecordsLimit, is_iso8601, get_next_page_url
1414
)
1515
from osisoft_pagination import OffsetPagination
1616
from safe_logger import SafeLogger
@@ -763,9 +763,15 @@ def search_attributes(self, database_webid, **kwargs):
763763
json_response = self.get(url=search_attributes_base_url, headers=headers, params=params)
764764
if OSIsoftConstants.DKU_ERROR_KEY in json_response:
765765
yield json_response
766-
items = json_response.get(OSIsoftConstants.API_ITEM_KEY, [])
767-
for item in items:
768-
yield item
766+
while json_response:
767+
next_page_url = get_next_page_url(json_response)
768+
items = json_response.get(OSIsoftConstants.API_ITEM_KEY, [])
769+
for item in items:
770+
yield item
771+
if next_page_url:
772+
json_response = self.get(url=next_page_url, headers={}, params={})
773+
else:
774+
json_response = None
769775

770776
def build_element_query(self, **kwargs):
771777
element_query_keys = {

python-lib/osisoft_constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ class OSIsoftConstants(object):
403403
"Security": "{base_url}/eventframes/{webid}/security",
404404
"SecurityEntries": "{base_url}/eventframes/{webid}/securityentries"
405405
}
406-
PLUGIN_VERSION = "1.2.3-beta.3"
406+
PLUGIN_VERSION = "1.2.3-beta.4"
407407
VALUE_COLUMN_SUFFIX = "_val"
408408
WEB_API_PATH = "piwebapi"
409409
WRITE_HEADERS = {'X-Requested-With': 'XmlHttpRequest'}

python-lib/osisoft_plugin_common.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,25 @@ def reorder_dataframe(unnested_items_rows, first_elements):
443443
return unnested_items_rows
444444

445445

446+
def fields_selector(data_type):
447+
# specifies the fields to be returned for each data type
448+
if data_type in ["Value", "EndValue"]:
449+
return "Links%3BTimestamp%3BValue%3BType%3BUnitsAbbreviation"
450+
else:
451+
return "Links%3BItems.Timestamp%3BItems.Value%3BItems.Type"
452+
453+
454+
def get_next_page_url(json):
455+
if not json:
456+
return None
457+
next_page_url = json.get("Links", {}).get("Next", "").replace('&', '&')
458+
if next_page_url:
459+
logger.info("Next page's url is {}".format(next_page_url))
460+
else:
461+
logger.info("No more pages available")
462+
return next_page_url
463+
464+
446465
class RecordsLimit():
447466
def __init__(self, records_limit=-1):
448467
self.has_no_limit = (records_limit == -1)

0 commit comments

Comments
 (0)