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

New Feature - Ability to access historical tags in script #1283

Merged

Conversation

adnanebrahimi
Copy link
Contributor

Describe the feature
This is a missed feature for the script engine to access historical tags in the script.
by accessing historical tags in the script, you can now calculate historical data and show them in the view.

Describe the solution you'd like

Creating a new system function $getHistoricalTags that accepts three arguments:

  1. Array of historical Tags
  2. Date for past date
  3. Date for recent date

Usage:
console.log(await $getHistoricalTags(['t_7b1017a7-10924aca','t_5ed33907-40b642d3'],'2024/06/01 - 00:00:00','2024/06/30 - 23:59:59'));

With this line of code, you will get historical data for June

Or you can get historical data until present time by passing empty string like this:

console.log(await $getHistoricalTags(['t_7b1017a7-10924aca','t_5ed33907-40b642d3'],'2024/06/01 - 00:00:00',''));

Output:

{
  "t_7b1017a7-10924aca": [
    { "x": "2024-06-30T20:30:00.000Z", "y": "1"},
    { "x": "2024-07-09T13:08:45.822Z", "y": "0" }
   ],
    "t_5ed33907-40b642d3": [
    { "x": "2024-06-30T20:30:00.000Z", "y": "0" },
    { "x": "2024-07-09T13:08:45.822Z", "y": "0" }
  ]
}

@adnanebrahimi adnanebrahimi changed the title Feature/get historical tag script New Feature - Ability to access historical tags in script Jul 20, 2024
@unocelli unocelli changed the base branch from master to pr1283 July 23, 2024 19:51
@unocelli unocelli merged commit a8b4270 into frangoteam:pr1283 Jul 23, 2024
@unocelli
Copy link
Member

Good work! I'm reviewing your PR.

@unocelli
Copy link
Member

Hi, in pr1283 branch I made a few changes, in particular the Date format is not compatible for internationality.
I hope you don't mind, please give me a feedback.

@adnanebrahimi
Copy link
Contributor Author

Hi, in pr1283 branch I made a few changes, in particular the Date format is not compatible for internationality. I hope you don't mind, please give me a feedback.

I will check it. Thank you for the review.

@adnanebrahimi
Copy link
Contributor Author

adnanebrahimi commented Jul 25, 2024

@unocelli
It's working as expected 👍
But In the deviceTagsSelectionComponent dialog, we added some changes that will list only historical tags if it is called in the getHistoricalTags function. it's not working.
image

By adding these two lines the dialog will show only historical tags

@unocelli
Copy link
Member

I have forgotten, I will add it to the pr. Thanks a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants