|
@@ -133,6 +133,24 @@ async def _local_refresh(start: date, end: date, args) -> None:
|
|
|
await local_refresh(start, end)
|
|
await local_refresh(start, end)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+async def _remote_sync(start: date, end: date, args) -> None:
|
|
|
|
|
+ from room_cal.actions.remote_sync import remote_sync
|
|
|
|
|
+ result = await remote_sync(start, end)
|
|
|
|
|
+ any_fixed = False
|
|
|
|
|
+ for svc, issues in result.items():
|
|
|
|
|
+ if not issues:
|
|
|
|
|
+ continue
|
|
|
|
|
+ any_fixed = True
|
|
|
|
|
+ n = len(issues)
|
|
|
|
|
+ print(f"\n Fixed: {svc} ({n} date{'s' if n != 1 else ''})")
|
|
|
|
|
+ _fmt_table(
|
|
|
|
|
+ [[str(i['date']), str(i['actual_rts']), str(i['expected_rts'])] for i in issues],
|
|
|
|
|
+ ['date', 'was', 'now'],
|
|
|
|
|
+ )
|
|
|
|
|
+ if not any_fixed:
|
|
|
|
|
+ print(" no issues found")
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
def _fmt_table(rows: list[list[str]], header: list[str]) -> None:
|
|
def _fmt_table(rows: list[list[str]], header: list[str]) -> None:
|
|
|
all_rows = [header] + rows
|
|
all_rows = [header] + rows
|
|
|
widths = [max(len(r[i]) for r in all_rows) for i in range(len(header))]
|
|
widths = [max(len(r[i]) for r in all_rows) for i in range(len(header))]
|
|
@@ -295,6 +313,18 @@ async def _diff(start: date, end: date, args) -> None:
|
|
|
rows.append([str(o['date']), o['event_type'], o['title'], src_str])
|
|
rows.append([str(o['date']), o['event_type'], o['title'], src_str])
|
|
|
_fmt_table(rows, ['date', 'type', 'title', 'source'])
|
|
_fmt_table(rows, ['date', 'type', 'title', 'source'])
|
|
|
|
|
|
|
|
|
|
+ remote_sync = result.get('remote_sync', {})
|
|
|
|
|
+ for svc, issues in remote_sync.items():
|
|
|
|
|
+ if not issues:
|
|
|
|
|
+ continue
|
|
|
|
|
+ any_diff = True
|
|
|
|
|
+ n = len(issues)
|
|
|
|
|
+ print(f"\n Remote sync issues: {svc} ({n} date{'s' if n != 1 else ''})")
|
|
|
|
|
+ _fmt_table(
|
|
|
|
|
+ [[str(i['date']), str(i['actual_rts']), str(i['expected_rts'])] for i in issues],
|
|
|
|
|
+ ['date', 'actual_rts', 'expected_rts'],
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
if not any_diff:
|
|
if not any_diff:
|
|
|
print(" no differences")
|
|
print(" no differences")
|
|
|
|
|
|
|
@@ -321,6 +351,7 @@ _ACTIONS: dict[str, tuple] = {
|
|
|
'push-busy': (_push_busy, 'Sync Busy export calendar from local closed and reservation events'),
|
|
'push-busy': (_push_busy, 'Sync Busy export calendar from local closed and reservation events'),
|
|
|
'local-sync': (_local_sync, 'Fetch all iCal feeds, apply rules, fill prices, and sync Busy — no service API calls'),
|
|
'local-sync': (_local_sync, 'Fetch all iCal feeds, apply rules, fill prices, and sync Busy — no service API calls'),
|
|
|
'local-refresh': (_local_refresh, 'Re-write all local Room calendar events (prices, closed, discounts, reservations)'),
|
|
'local-refresh': (_local_refresh, 'Re-write all local Room calendar events (prices, closed, discounts, reservations)'),
|
|
|
|
|
+ 'remote-sync': (_remote_sync, 'Integrity-check and repair service-side data (e.g. Booking.com rooms_to_sell drift)'),
|
|
|
'diff': (_diff, 'Compare local CalDAV data to live service APIs and report all differences (read-only)'),
|
|
'diff': (_diff, 'Compare local CalDAV data to live service APIs and report all differences (read-only)'),
|
|
|
}
|
|
}
|
|
|
|
|
|