- Fix UTC display bug: upload_nrl_data now wraps RNH datetimes with
local_to_utc() before storing, matching patch_session behavior.
Period type and label are derived from local time before conversion.
- Add period_start_hour / period_end_hour to MonitoringSession model
(nullable integers 0–23). Migration: migrate_add_session_period_hours.py
- Update patch_session to accept and store period_start_hour / period_end_hour.
Response now includes both fields.
- Update get_project_sessions to compute "Effective: M/D H:MM AM → M/D H:MM AM"
string from period hours and pass it to session_list.html.
- Rework period edit UI in session_list.html: clicking the period badge now
opens an inline editor with period type selector + start/end hour inputs.
Selecting a period type pre-fills default hours (Day: 7–19, Night: 19–7).
- Wire period hours into _build_location_data_from_sessions: uses
period_start/end_hour when set, falls back to hardcoded defaults.
- RND viewer: inject SESSION_PERIOD_START/END_HOUR from template context.
renderTable() dims rows outside the period window (opacity-40) with a
tooltip; shows "(N in period window)" in the row count.
- New session detail page at /api/projects/{id}/sessions/{id}/detail:
shows breadcrumb, files list with View/Download/Report actions,
editable session info form (label, period type, hours, times).
- Add local_datetime_input Jinja filter for datetime-local input values.
- Monthly calendar view: new get_sessions_calendar endpoint returns
sessions_calendar.html partial; added below sessions list in detail.html.
Color-coded per NRL with legend, HTMX prev/next navigation, session dots
link to detail page.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
43 lines
1.2 KiB
Python
43 lines
1.2 KiB
Python
"""
|
|
Migration: add period_start_hour and period_end_hour to monitoring_sessions.
|
|
|
|
Run once:
|
|
python backend/migrate_add_session_period_hours.py
|
|
|
|
Or inside the container:
|
|
docker exec terra-view python3 backend/migrate_add_session_period_hours.py
|
|
"""
|
|
|
|
import sys
|
|
import os
|
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
|
from backend.database import engine
|
|
from sqlalchemy import text
|
|
|
|
def run():
|
|
with engine.connect() as conn:
|
|
# Check which columns already exist
|
|
result = conn.execute(text("PRAGMA table_info(monitoring_sessions)"))
|
|
existing = {row[1] for row in result}
|
|
|
|
added = []
|
|
for col, definition in [
|
|
("period_start_hour", "INTEGER"),
|
|
("period_end_hour", "INTEGER"),
|
|
]:
|
|
if col not in existing:
|
|
conn.execute(text(f"ALTER TABLE monitoring_sessions ADD COLUMN {col} {definition}"))
|
|
added.append(col)
|
|
else:
|
|
print(f" Column '{col}' already exists — skipping.")
|
|
|
|
conn.commit()
|
|
|
|
if added:
|
|
print(f" Added columns: {', '.join(added)}")
|
|
print("Migration complete.")
|
|
|
|
if __name__ == "__main__":
|
|
run()
|