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

last_element_min_time #95

Merged
merged 1 commit into from
Nov 17, 2023
Merged

Conversation

clavay
Copy link
Collaborator

@clavay clavay commented Nov 15, 2023

set min time to 0 if no min time is set

set to 0 if no min time set
@clavay clavay requested a review from trombastic November 15, 2023 09:50
@clavay
Copy link
Collaborator Author

clavay commented Nov 15, 2023

@trombastic What do you think about changing this behavior ?

@trombastic
Copy link
Collaborator

this seems to be a good choice for the default value in general, how ever this will return all data if no time_min is provided and this will take a lot of time if used accidentally on a large dataset. Do you know if this method is used without time_min in a view?

@clavay
Copy link
Collaborator Author

clavay commented Nov 16, 2023

the function last_element returns only one element, the last one in the time range.

it is used with time_min=0 here:

PyScada/pyscada/models.py

Lines 604 to 609 in 83ae3f2

last_element = self.last_element(
use_date_saved=True,
time_min=0,
time_max=time_max_last_value,
variable_id=pk,
)

it should be used with time_min=0 here:

actual_value = RecordedData.objects.last_element(variable=self.variable)

PyScada/pyscada/models.py

Lines 3725 to 3727 in 83ae3f2

limit_value = RecordedData.objects.last_element(
variable=self.variable_limit
)

element = RecordedData.objects.last_element(variable_id=instance.pk)

@trombastic trombastic merged commit 9e156ba into pyscada:main Nov 17, 2023
@clavay clavay deleted the last_element_min_time branch November 24, 2023 12:59
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.

2 participants