Kagodora Updates
Development Journal ā Ray 2044 – 2026-05-12
Issue Summary
The Kagodora KaDo time system exhibited two critical problems:
- Ring (AhReIEnGo) did not advance correctly
- The plugin stored a manual ring value (
ahreienqo) in the database, but the frontāpage display computed the ring from ray using an incorrect starting point (ray 2009 = ring 1). - The correct timeline requires ring 6 to begin at ray 1801, with ray 2009 being the 208th ray of ring 6, and ring 7 starting at ray 2161.
- The plugin stored a manual ring value (
- Frontāend time reset to a future value on refresh
- The JavaScript used a staticĀ
updatedĀ timestamp from the database that never changed after a āSave Current Timeā operation. - Without updating the reference timestamp, each page refresh added the elapsed time since the original save, causing the displayed time to jump ahead of real time.
- The JavaScript used a staticĀ
Root Causes
- Ring math error:Ā
totalRings = floor((ray - 2009)/360) + 1Ā assumed epoch at ray 2009, but the real epoch starts at ray 1801 (ring 6). - Missing timestamp update:Ā The AJAX save handler did not refresh theĀ
updatedĀ column. The JavaScript also did not reset its internalĀstate.timestampĀ after a successful save. - Conflicting data sources:Ā The database storedĀ
ahreienqoĀ separately from the computed ring, causing potential inconsistency between admin settings and frontāend display.
Remedies Applied
1. Corrected Ring Calculation
In PHP (helper function):
phpCopyDownload
function mathorian_kagodora_compute_ring($ray) {
return 6 + floor(($ray - 1801) / 360);
}
In JavaScript (mirrored logic):
javascriptCopyDownload
function computeRing(ray) {
let ring = 6 + Math.floor((ray - 1801) / 360);
return ring < 1 ? 1 : ring;
}
Now ray 1801 ā ring 6, ray 2161 ā ring 7, etc.
2. Unified Ring Source
- The frontāpageĀ
AhReIEnGoĀ display now always callsĀcomputeRing(ray)Ā ā no longer relies on a stored value. - The admin settings page shows the ring asĀ readāonly, computed from the current ray.
- When saving any time update (via āSave Current Timeā or admin form), theĀ
ahreienqoĀ column is automatically set to the computed ring. This keeps the database consistent without allowing manual override.
3. Fixed Timestamp Drift
In the AJAX save handler (PHP):
phpCopyDownload
$wpdb->update($table, compact('ahta','ahsa','ahgo','ahdo','ray','ahreienqo'), ['id'=>1]);
$wpdb->update($table, ['updated' => current_time('mysql')], ['id' => 1]);
In JavaScript (saveCurrentTime function):
javascriptCopyDownload
fetch(ajaxUrl, { method: 'POST', body: params })
.then(res => {
if (res.ok) {
state.timestamp = Date.now() / 1000; // reset local reference
}
});
Now every āSave Current Timeā operation updates both the database updated column and the JavaScript state.timestamp, so the elapsed time calculation starts fresh from that moment.
Outcome
- Ring increments correctlyĀ every 360 rays, matching the intended calendar (ring 6 from ray 1801, ring 7 from 2161, etc.).
- Frontāend time persists accuratelyĀ across page refreshes and browser restarts.
- Admin settings and front page remain in syncĀ ā the ring is always derived from the ray, eliminating conflicting values.
- āSet Time / Calibrateā and āSave Current Timeā buttonsĀ now fully respect the corrected math and update the reference timestamp.
Next Steps
- Monitor the system for any further drift, especially across long periods without updates.
- Consider adding a serverāside cron job that automatically saves the current time every day to keep the database timestamp fresh even if the frontāend is not visited.
- Document the new ring formula for future reference.

Leave a Reply