Skip to content

Conversation

@swiffer
Copy link
Collaborator

@swiffer swiffer commented Apr 21, 2025

Grafana is not setting the PostgreSQL session timezone. To ensure truncation is done with respect to the Grafana timezone setting set the optional time_zone argument for DATE_TRUNC().

Fixes #4675

@swiffer swiffer changed the title set $__timezone explicitly fix: set $__timezone explicitly Apr 21, 2025
@netlify
Copy link

netlify bot commented Apr 21, 2025

Deploy Preview for teslamate ready!

Name Link
🔨 Latest commit 62c0c2a
🔍 Latest deploy log https://app.netlify.com/sites/teslamate/deploys/68075fedd88aeb0007e8d6d0
😎 Deploy Preview https://deploy-preview-4684--teslamate.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@swiffer swiffer self-assigned this Apr 21, 2025
@swiffer swiffer added area:grafana Related to Grafana area:dashboard Related to a Grafana dashboard and removed area:grafana Related to Grafana labels Apr 21, 2025
@JakobLichterfeld JakobLichterfeld changed the title fix: set $__timezone explicitly fix: set $__timezone explicitly in dashboards to ensure correct timezone handling Apr 21, 2025
@JakobLichterfeld JakobLichterfeld changed the title fix: set $__timezone explicitly in dashboards to ensure correct timezone handling fix: set $__timezone explicitly in dashboards to ensure truncation is done with respect to the Grafana timezone Apr 21, 2025
Copy link
Member

@JakobLichterfeld JakobLichterfeld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!
Unfortunately there seems to be some syntax error in Drive Stats
image

v1.33.0 as comparison:
image

@swiffer
Copy link
Collaborator Author

swiffer commented Apr 21, 2025

on it

@JakobLichterfeld
Copy link
Member

JakobLichterfeld commented Apr 21, 2025

Number of drives is different as well

@swiffer
Copy link
Collaborator Author

swiffer commented Apr 21, 2025

yes, drives happening over night have been missing so far - current number should be correct. can you compare with drives dashboard?

@JakobLichterfeld
Copy link
Member

JakobLichterfeld commented Apr 21, 2025

Syntax Error is fixed, ty!

yes, drives happening over night have been missing so far - current number should be correct. can you compare with drives dashboard?

Nope, drives dashboard shows 122 rows for last 6 months which seems to be right
image

v1.33.0 drive stats dashboard shows same number but #4684 does show 137

No overnight drives as of my knowledge

@swiffer
Copy link
Collaborator Author

swiffer commented Apr 21, 2025

Okay, will have a look...

@JakobLichterfeld JakobLichterfeld marked this pull request as draft April 21, 2025 08:27
@DrMichael
Copy link
Collaborator

DrMichael commented Apr 21, 2025

Let's collect it here...
#4675 (comment)
Almost there... :-)
You still need to replace in the Statistics' dashboard the CASE $period's the date by TIMEZONE('$__timezone', date).
Currently, the period shows up correctly in my edge case, but the period is the day before...

Charging Stats for my edge case looks good. I don't have drives between 00:00 and 01:00...

Perhaps @giterdone509 can also test it. He is 4 hours off UTC...

@swiffer
Copy link
Collaborator Author

swiffer commented Apr 21, 2025

@JakobLichterfeld do you have any incomplete drives? drives dashboard and stat are identical looking at my data 🤔

@JakobLichterfeld
Copy link
Member

JakobLichterfeld commented Apr 21, 2025

@JakobLichterfeld do you have any incomplete drives? drives dashboard and stat are identical looking at my data 🤔

Yeah but not in this timeframe as of my knowledge, that's why I choose the 6 month period
Edit: 15 incomplete drives on 2024-11-04, so in the period, my fault.

@swiffer
Copy link
Collaborator Author

swiffer commented Apr 21, 2025

ok, should those be ex or included?

@swiffer
Copy link
Collaborator Author

swiffer commented Apr 21, 2025

@DrMichael - thanks checking this! fixed all places where making use of to_char!

@DrMichael
Copy link
Collaborator

DrMichael commented Apr 21, 2025

@DrMichael - thanks checking this! fixed all places where making use of to_char!

My pleasure. Thanks for your work...

@swiffer swiffer marked this pull request as ready for review April 21, 2025 11:27
@JakobLichterfeld
Copy link
Member

JakobLichterfeld commented Apr 21, 2025

ok, should those be ex or included?

A drive is a drive, innit? So in my case it is one drive which was split in 15 due to whatever reason.
So as a user I would expect unclosed drives to be included.
Or we write number of finished drives

@swiffer
Copy link
Collaborator Author

swiffer commented Apr 21, 2025

Ready to be merged

@JakobLichterfeld
Copy link
Member

ok, should those be ex or included?

A drive is a drive, innit? So in my case it is one drive which was split in 15 due to whatever reason.
So as a user I would expect unclosed drives to be included.
Or we write number of finished drives

Sorry, during my run in the woods I changed my mind. We do handle unclosed drives and charges as corrupt in other places, aren't we? So they should not be included and you are right.

@swiffer
Copy link
Collaborator Author

swiffer commented Apr 21, 2025

ok, done ;)

Copy link
Member

@JakobLichterfeld JakobLichterfeld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully tested. Ty!
And sorry for the back and forth

@JakobLichterfeld JakobLichterfeld merged commit 4b6e5bb into master Apr 22, 2025
24 checks passed
@JakobLichterfeld JakobLichterfeld deleted the swiffer/fix-4675 branch April 22, 2025 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:dashboard Related to a Grafana dashboard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect filter for daily statistics dashboard

4 participants