Welcome to the Cumulus Support forum.

Latest Cumulus MX V4 release 4.4.2 (build 4085) - 12 March 2025

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Legacy Cumulus 1 release 1.9.4 (build 1099) - 28 November 2014
(a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

If you are posting a new Topic about an error or if you need help PLEASE read this first viewtopic.php?p=164080#p164080

SQL Bug or something else?

From build 3044 the development baton passed to Mark Crossley. Mark has been responsible for all the Builds since. He has made the code available on GitHub. It is Mark's hope that others will join in this development, but at the very least he welcomes your ideas for future developments (see Cumulus MX Development suggestions).

Moderator: mcrossley

Post Reply
Mapantz
Posts: 1992
Joined: Sat 17 Dec 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 11 x64
Location: Dorset - UK
Contact:

SQL Bug or something else?

Post by Mapantz »

I was looking at the database that CMX uploads my GW-1000 data to yesterday, and noticed a discrepancy..

I insert lightning data in to the database using the 'Custom upload at rollover' function as follows:

Code: Select all

INSERT IGNORE INTO Lightning (LogDate,StrikesToday) VALUES ('<#date format=yyyy-MM-dd>',<#LightningStrikesToday>)
I noticed that the last entry was the 18th April, even though it was currently the 18th. I scrolled back through the data and noticed that the 12th March was missing, it just went from the 11th to the 13th.

Easy fix, I just manually added in the 12th and deleted the latest entry (18th) as I thought CMX would populate it correctly at the rollover.

I just checked the database again and noticed that it skipped the 18th and added in the 19th. :|

All rather confusing!
Annotation 2020-04-19 132423.png
You do not have the required permissions to view the files attached to this post.
Image
freddie
Posts: 2870
Joined: Wed 08 Jun 2011 11:19 am
Weather Station: Davis Vantage Pro 2 + Ecowitt
Operating System: GNU/Linux Ubuntu 24.04 LXC
Location: Alcaston, Shropshire, UK
Contact:

Re: SQL Bug or something else?

Post by freddie »

Isn't the date tag rolled over just before the end-of-day functions run?
Freddie
Image
sfws
Posts: 1183
Joined: Fri 27 Jul 2012 11:29 am
Weather Station: Chas O, Maplin N96FY, N25FR
Operating System: rPi 3B+ with Buster (full)

Re: SQL Bug or something else?

Post by sfws »

freddie wrote: Sun 19 Apr 2020 1:09 pm Isn't the date tag rolled over just before the end-of-day functions run?
Mark commented on this in my topic about SQl, I have not checked what he said, but the gist was it uses system date, so that does indeed change at start of rollover, before any End of Day processes. To my mind, they should be renamed "Start of Day" processes.

In my case, I was using <#metdate> and had to change to using <#metdateyesterday>, but the SQL amended from I had in that topic is still not working correctly. I'm guessing this could also give me end of month problems, so I'm sticking to using my PHP scripts instead of relying on the MX functionality.

None of this explains why it should have missed a date in the past unless something was edited on that date, it would only explain rows being consistently created with wrong date as I experienced at first.
Mapantz
Posts: 1992
Joined: Sat 17 Dec 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 11 x64
Location: Dorset - UK
Contact:

Re: SQL Bug or something else?

Post by Mapantz »

A custom SQL command to be executed just before end of day rollover - can include webtags
Much like the dayfile entry - it adds the stats of the day just before midnight.

I'm pretty sure it was working correctly before it missed a day out (not sure how that happened) but since then, it seems to be adding an extra day on to it.
Image
User avatar
mcrossley
Posts: 14388
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: SQL Bug or something else?

Post by mcrossley »

The custom commands are run after the rollover (so the aggregated stats for the day just ended are available). Therefore if you use a midnight rollover the <#date> tag will show the current date, i.e. the day after the rollover. If using a custom SQL command you will have to use yesterdays date as explained above.
Mapantz
Posts: 1992
Joined: Sat 17 Dec 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 11 x64
Location: Dorset - UK
Contact:

Re: SQL Bug or something else?

Post by Mapantz »

ah - I was unaware in ran the command after the rollover. The bit that says it runs before the rollover threw me. :twisted:
Image
User avatar
mcrossley
Posts: 14388
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: SQL Bug or something else?

Post by mcrossley »

Mapantz wrote: Sun 19 Apr 2020 4:57 pm ah - I was unaware in ran the command after the rollover. The bit that says it runs before the rollover threw me. :twisted:
I'm going to be digging into the rollover code tonight - let me fact check myself! :lol:
sfws
Posts: 1183
Joined: Fri 27 Jul 2012 11:29 am
Weather Station: Chas O, Maplin N96FY, N25FR
Operating System: rPi 3B+ with Buster (full)

Re: SQL Bug or something else?

Post by sfws »

mcrossley wrote: Sun 19 Apr 2020 5:14 pm I'm going to be digging into the rollover code tonight - let me fact check myself! :lol:
So you might actually respond to my question "am I right" on viewtopic.php?f=40&t=17951#p140232
User avatar
mcrossley
Posts: 14388
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: SQL Bug or something else?

Post by mcrossley »

mcrossley wrote: Sun 19 Apr 2020 5:14 pm I'm going to be digging into the rollover code tonight - let me fact check myself! :lol:
OK, wrong! I recalled incorrectly, the boiler plate is correct, in that the custom SQL commands are called before the rollover processing. BUT of course the rollover is triggered *just* after midnight (for midnight rollover), so the date will be the following day, hence the need to use yesterdays date.
Mapantz
Posts: 1992
Joined: Sat 17 Dec 2011 11:55 am
Weather Station: Davis Vantage Pro2
Operating System: Windows 11 x64
Location: Dorset - UK
Contact:

Re: SQL Bug or something else?

Post by Mapantz »

All good!

Used <#metdateyesterday> as was suggested - working as it should. Thank you! :D
Image
Post Reply