Skip to content

Feat/daysamples update#76

Open
hiddn wants to merge 2 commits intoUndernetIRC:masterfrom
hiddn:feat/daysamples-update
Open

Feat/daysamples update#76
hiddn wants to merge 2 commits intoUndernetIRC:masterfrom
hiddn:feat/daysamples-update

Conversation

@hiddn
Copy link
Copy Markdown
Member

@hiddn hiddn commented Mar 28, 2026

openchanfix: auto-migrate chanops_daily when daySamples changes

I also applied changes ( commit f47da22) based on @Ratler's comments.

hiddn added 2 commits March 27, 2026 17:49
Store the current daySamples value in a new 'variables' table.
On startup, if the config value differs from the stored value:
- If shrinking, prune day slots outside the new window
- Shift chanops_daily.day values so currentDay maps to the same data
- Update the stored value

This prevents score data from becoming misaligned when the
daysamples config parameter is changed between restarts.

Migration 003 creates the variables table and seeds it with
the default value of 14.
…mples

- Replace UPDATE with UPSERT (INSERT ... ON CONFLICT DO UPDATE) when
  persisting the new daysamples value, preventing a silent noop that
  would cause the day-slot shift to be re-applied on every restart.

- Use escapeSQLChars() on the daysamples value embedded in the SQL
  string literal, consistent with the rest of the codebase.

- Treat daysamples < 1 as a fatal config error (exit on startup)
  instead of silently falling back to 14, to prevent a zero-modulus
  crash if the value somehow reaches the arithmetic in migrateDaySamples.
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.

1 participant