Commit Graph
317 Commits
Author SHA1 Message Date
popertotsandSisyphus a4fa75154d refactor: centralize scheduling cleanup with row-count returns
Convert all scheduling cleanup functions to return (int, error). Remove inline cleanup calls from GetAvailableHours. Add scheduled-cleanup.go for centralized job wrappers.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-07-07 00:09:51 +01:00
popertotsandSisyphus 72161e8c4f docs(backend): clarify auth fallback rationale in reserve handler
CI / Go vulnerabilities (push) Successful in 37s
CI / Tests (push) Successful in 1m33s
CI / Frontend lint & types (push) Successful in 1m46s
CI / Race detector (push) Successful in 3m38s
Expands inline comments to explain why the Bearer token fallback is deliberately kept — it serves 22+ test invocations that call ReserveSlotHandler directly without middleware, never executes in production, and acts as defense-in-depth.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-07-06 19:22:08 +01:00
popertotsandSisyphus e303c07f8d refactor(backend): replace inline Bearer parsing with OptionalAuth middleware in services
Removes the inline Bearer token fallback in ServicesHandler — the OptionalAuth middleware (added to the public services route group in main.go) now handles auth context population. This eliminates duplicated token parsing logic and ensures consistent auth behavior across all routes.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-07-06 19:22:00 +01:00
popertots c2aa0b93cb feat(api): add admin reservation cancel endpoint
Add DELETE /api/admin/bookings/reserve to release admin walk-in/call-in reservations.

New handler AdminCancelReservationHandler targets only RESERVATION:admin:%
entries (partitioned from user RESERVATION:user:% by WHERE clause). Includes
12 tests covering walkin + callin success, isolation, no-op, unauth, empty ctx,
walkin+callin coexistence, anon untouched, response format parity, overlapping
reservations deleted, user reservations untouched, and idempotent double-cancel.

Inverse-isolation tests in cancel_reservation_test.go prove the user-side
DELETE /api/bookings/reserve does not touch admin or anon reservations.
2026-07-06 17:58:03 +01:00
popertotsandSisyphus be22710f7b test: add scheduling excludeUserID integration test
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-07-05 20:26:40 +01:00
popertotsandSisyphus 2e0760f083 feat: add IP-based anon reservation cleanup to admin reserve handler
Extend AdminReserveSlotHandler's pre-overlap DELETE to also clean up anonymous RESERVATION:anon entries matching the admin's IP address. This handles the edge case where an admin previously reserved a slot without authentication. Also reorganise imports to follow goimports conventions.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-07-05 20:26:33 +01:00
popertotsandSisyphus cc6ad7f00f fix: remove t.Parallel from VAT lifecycle test
CI / Go vulnerabilities (push) Successful in 33s
CI / Tests (push) Successful in 1m28s
CI / Frontend lint & types (push) Successful in 1m45s
CI / Race detector (push) Successful in 3m28s
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-07-05 20:08:12 +01:00
popertotsandSisyphus 30c9012562 fix: move dav.Service init from auth_test to user testmain
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-07-05 20:08:09 +01:00
popertotsandSisyphus 33c945159c feat: add cancel reservation handler and background cleanup
Add CancelReservationHandler (DELETE /api/bookings/reserve) to release authenticated user's active reservation. Register route in main.go. Add background goroutine for periodic reservation cleanup using CleanupOldReservations. Add idx_time_blockers_created_at index and extend anon cleanup to cover edit_request reservations in init-script.sql.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-07-05 11:47:54 +01:00
popertotsandSisyphus 2386bd0ca2 test: add tests for reservation self-block prevention
Add TestReserveSlot_DoesNotSelfBlock, TestAdminReserveSlot_DoesNotSelfBlock and TestReserveSlot_CleansUpAnonReservation. Add UserIDKey context to admin approve edit request tests. Remove weekend-day adjustment in TestAdminApproveEditRequest_OverlapWithBooking_Regression and TestAdminApproveEditRequest_EvictsPendingRelease (no longer needed).

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-07-05 11:47:43 +01:00
popertotsandSisyphus c1a9f35ea5 feat: prevent reservation self-block in booking handlers
Pass excludeUserID to CheckTimeBlockerOverlap in AdminReserveSlotHandler, CreateBookingHandler, EditBookingHandler, AdminRescheduleBookingHandler, AdminCreateBookingForUserHandler, AdminApproveEditRequestHandler, and ReserveSlotHandler. Also clean up stale reservations before overlap check in AdminReserveSlotHandler and ReserveSlotHandler via db.Conn.Exec for cross-connection visibility. Improve error handling in RequestEditHandler's service update block.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-07-05 11:45:02 +01:00
popertotsandSisyphus 920eb761fd feat: add excludeUserID param to scheduling time blockers
Add optional excludeUserID parameter to GetTimeBlockersInRange and CheckTimeBlockerOverlap so a user's own RESERVATION entries are excluded from overlap checks. This prevents users from self-blocking on their existing reservation when checking availability or confirming a booking.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-07-05 11:44:52 +01:00
popertots 766b5b7dbd fix(vat): resolve non-deterministic ORDER BY in TestVAT_ToggleLifecycle
Frontend Lint & Vulns / Lint & vulns (push) Failing after 48s
The phase 3 payment query used ORDER BY created_at DESC LIMIT 1.
Within a single transaction, NOW() returns the same timestamp for all
inserts, making the ordering non-deterministic when other parallel tests
insert payment rows with the same timestamp. Fix by parsing the
response's payment ID and querying by it directly.

Also revert eslint.config.js back to error-level rules for all categories
(removing the previous 'warn' overrides).
2026-06-25 14:12:48 +01:00
popertotsandSisyphus e4b9003439 refactor(handlers): migrate remaining backend handlers to clock.Now() and transaction patterns
Apply clock.Now() migration, transaction wrapping, and minor refactors across admin, scheduling, today, user, auth handler, notifications, webhooks, services, portfolio, ratelimit, testutils, and main.go.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-24 23:43:50 +01:00
popertotsandSisyphus 7b24f8e484 refactor(payments): integrate VAT into gift card buy flow and wrap in transactions
Refactor BuyGiftCard to insert pending payment before Square call with VAT applied. Add transaction wrapping to gift card handlers. Remove redundant Content-Type header sets. Migrate all time.Now() to clock.Now().

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-24 23:43:40 +01:00
popertotsandSisyphus 40bbd9ba49 refactor(bookings): migrate remaining handlers and tests to clock.Now()
Replace time.Now() with clock.Now() in bookings handlers and all test files. Includes deposit, discount, dedup, overlap, and edit request test updates.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-24 23:43:32 +01:00
popertotsandSisyphus 0ea1bb64b4 feat(bookings): add closing_time validation and repo layer
Extract closing hours check into reusable checkClosingHours helper. Add repo.go for shared DB query helpers. Update admin_reserve to use closing_time and move overlap check inside transaction with FOR UPDATE.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-24 23:43:23 +01:00
popertotsandSisyphus 37a9ba3517 fix(bookings): use transaction context for discount check in approve edit
Use tx.QueryRow instead of db.Conn.QueryRow for discount count check in AdminApproveEditRequestHandler to ensure consistency within the transaction.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-22 17:06:18 +01:00
popertotsandSisyphus 80b9877686 feat(api): add public business info route and TotalVATCollected to daily summary
Expose GET /business-info public endpoint for non-admin users. Add TotalVATCollected field to DailySummary and compute it in the aggregate query.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-22 17:06:12 +01:00
popertotsandSisyphus 7756f3af96 test(scheduling): add exhaustive blocker, gap, and cross-day tests
Add comprehensive time blocker tests: multiple blockers, blocker+booking combination, all-day, non-overlapping, multi-day, boundary start/end, out-of-hours, recurring (cron), reservation, overlapping, adjacent, cross-day midnight, closed days, exceptional hours. Add subtractTimeSlots and normalizeTime unit tests.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-22 17:06:05 +01:00
popertotsandSisyphus edc7d833ea refactor(scheduling): split multi-day blockers and normalize time strings
Split multi-day time blockers into per-day segments for subtractTimeSlots. Add normalizeTime helper to strip seconds from HH:MM:SS for consistent comparison. Subtract blockers for all users (not just non-admin) to prevent 409 errors on reserve. Move late-night lock logic to separate block.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-22 17:05:58 +01:00
popertotsandSisyphus 9d70d42bd4 test(admin): add settings validation, public info, and out_of_hours tests
Add comprehensive tests for business settings validation (name length, phone, email, VAT number, URL, voucher type, VAT rate). Add GetPublicBusinessInfo tests verifying correct JSON shape. Add out_of_hours field search tests for admin booking search.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-22 17:05:52 +01:00
popertotsandSisyphus 280b05bd34 feat(admin): add public business info, input validation, and VAT enable
Add GetPublicBusinessInfo endpoint for non-admin users. Add URL validation for website_url. Add length/bounds validation for name, address, phone, email, VAT number. Retroactively apply VAT to past payments/till sales when is_vat_registered is enabled.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-22 17:05:45 +01:00
popertotsandSisyphus 6561ceb7a9 feat(payments): integrate VAT into gift cards, payment handlers, and till sales
Track voucher_type_at_purchase on gift card creation. Apply VAT at gift card purchase (SPV), at redemption (MPV). Use transaction-aware GetCardByIDQuerier for till saved card lookups. Apply VAT to all booking payments (split records, terminal, tip, checkout). Add TotalVATAmount and TotalNetAmount to PaymentSummary responses.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-22 17:05:39 +01:00
popertotsandSisyphus 7cd71e4485 feat(payments): add VAT config helper and apply functions
Add GetVATConfig for reading VAT settings via any db.Querier, ApplyVATToBookingPayment for applying VAT to payment records, and ApplyVATToTillSale for SPV gift card till sales. Errors are logged without blocking payment flow.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-22 17:05:31 +01:00
popertotsandSisyphus 34aba319f1 test(admin): add t.Parallel() to exceptional hours test
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-22 12:55:24 +01:00
popertotsandSisyphus b4f70ada49 fix(today): use date string instead of time.Date for exceptional hours query
Replace time.Date with formatted date string for exceptional hours query parameters to ensure correct PostgreSQL type inference.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-22 12:55:16 +01:00
popertotsandSisyphus 8ad0111954 feat(scheduling): add out_of_hours override and fix timezone handling
Support out_of_hours query param in GetWorkingHours and GetAvailableHours (admin-only, returns 06:00-22:00 for all days). Replace ukLocation with time.Local for date boundaries. Add OptionalAuth middleware to scheduling routes for admin role detection. Add tests for admin/non-admin/no-auth scenarios, booking respect, and exceptional hours interaction.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-22 12:55:08 +01:00
popertotsandSisyphus 8ab7408e00 feat(bookings): support out_of_hours flag in admin create booking
Add OutOfHours field to AdminCreateBookingForUserRequest. When true, skip exceptional hours closed check and include out_of_hours in INSERT. Add tests verifying: bypass of exceptional closure, rejection without flag, overlap detection still works, and time blocker warning.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-22 12:55:00 +01:00
popertotsandSisyphus 7698ca636b feat(bookings): support out_of_hours flag in admin reserve handler
Add OutOfHours field to AdminReserveSlotRequest. When true, skip the closing hours check allowing admin to reserve slots outside normal business hours. Add tests for call-in, walk-in, without-flag failure, and time blocker interaction.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-22 12:54:52 +01:00
popertotsandSisyphus 260c760971 feat(bookings): add out_of_hours field to Booking struct and admin queries
Include out_of_hours in GetAllAdminBookings, GetAdminBooking, and SearchAdminBookings queries. Add tests verifying out_of_hours appears in single and list booking responses.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-22 12:54:44 +01:00
popertotsandSisyphus 8b703a19ba refactor(today): consolidate aggregate summary into single query
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-22 00:57:59 +01:00
popertotsandSisyphus 0d940e8608 refactor(bookings): use computed booking fields and LATERAL joins
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-22 00:57:55 +01:00
popertotsandSisyphus bdee60d34f refactor(scheduling): batch queries and DRY retention filter
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-22 00:57:51 +01:00
popertotsandSisyphus 5bdac7d275 feat(bookings): add trigger tests for booking computed fields
Add test suite for PL/pgSQL trigger that auto-recalculates bookings.total_duration_minutes, bookings.total_amount, and bookings.end_time when booking_services or booking_custom_services change.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-21 21:47:35 +01:00
popertotsandSisyphus 1564f93d25 fix(user): fix column aliases and replace SELECT * with explicit columns
Fix customer_relationship.go: use consistent 'cnt' alias instead of duplicate 'count' column. Fix profile.go: replace SELECT * with explicit column list to avoid new computed booking columns breaking the admin listing query.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-21 21:47:31 +01:00
popertotsandSisyphus 95e0384f90 refactor(today): replace inline duration queries with booking.end_time
Simplify auto-transition queries in GetCurrentAndNextHandler by using bookings.end_time computed column instead of inline start_time + duration calculations. Remove ::text casts from end_time columns.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-21 21:47:26 +01:00
popertotsandSisyphus 741107df89 refactor(scheduling): replace inline duration queries with booking fields
Simplify scheduling handlers by using bookings.total_duration_minutes and bookings.end_time computed columns instead of inline UNION sub-queries for duration calculations. Remove unnecessary ::text casts from end_time columns (using native timestamptz).

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-21 21:47:22 +01:00
popertotsandSisyphus 14df08e129 refactor(payments): replace inline total_amount queries with booking field
Simplify payment handlers by using bookings.total_amount computed column instead of inline UNION sub-queries calculating price totals from booking_services and booking_custom_services.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-21 21:47:16 +01:00
popertotsandSisyphus 7ea6fab3af refactor(bookings): replace inline computed queries with booking fields
Simplify bookings handlers by using bookings.total_duration_minutes, bookings.total_amount, and bookings.end_time computed columns instead of inline UNION sub-queries against booking_services/booking_custom_services.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-21 21:47:12 +01:00
popertotsandSisyphus 96dd9e191c refactor(bookings): remove AdminEditBookingHandler and streamline booking creation/edit overlap checks
- manage.go: remove AdminEditBookingHandler (superseded by EditBookingHandler with overlap detection)

- manage.go: move overlap check inside transaction in AdminCreateBookingForUserHandler

- manage.go: add error handling to unchecked QueryRow calls in RequestEditHandler

- manage.go: reorder time_blocker deletion before overlap check in AdminApproveEditRequestHandler

- admin/bookings_test.go: remove tests for removed AdminEditBookingHandler

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-21 21:01:27 +01:00
popertotsandSisyphus ed14df9a99 fix(bookings): add error handling for unchecked QueryRow and improve overlap detection
- admin_reserve.go, reserve.go: wrap unchecked QueryRow.Scan with error handling

- bookings.go: replace next-booking overlap check with COUNT(*) in UpdateBookingServicesHandler

- bookings.go: wrap EditBookingHandler in a transaction with EvictPendingReleaseOverlapping

- bookings.go: add error handling for QueryRow and Evict in ConfirmBookingHandler

- bookings.go: add error handling and eviction reorder in AdminRescheduleBookingHandler

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-21 21:01:22 +01:00
popertotsandSisyphus e23cc3cc6f feat(bookings): add comprehensive overlap detection tests
Covers admin create, user edit, auto-approve, service duration extension, reserve, admin reserve, admin reschedule, confirm, and admin approve edit request — all with overlap edge cases.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-21 21:01:17 +01:00
popertotsandSisyphus 88892059c5 fix(scheduling): include reservations in GetTimeBlockersInRange and fix booking overlap query
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-21 21:00:47 +01:00
popertotsandSisyphus 220a0ef6e8 refactor(backend): update test files for PoolProxy and per-test transactions
Migrate all test files from SetupTestDB/db.DB pattern to per-test transactions:

- Replace SetupTestDB(t) with SetupTestTx(t) for context + transaction
- Replace db.DB.Query/QueryRow/Exec with tx.Query/QueryRow/Exec
- Replace context.Background() with context from SetupTestTx
- Replace defer rows.Close() pattern with explicit rows.Close()
- Add testdb.SeedBaseline(pool) to all TestMain functions
- Wire db.Conn = db.NewPoolProxy(pool) in all TestMain functions

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-21 19:29:24 +01:00
popertotsandSisyphus 3d0e2afc4c refactor(backend): migrate db.DB to db.Conn PoolProxy across all handlers
Replace direct *pgxpool.Pool usage with PoolProxy wrapper across the entire backend:

- db.DB renamed to db.Conn (*pgxpool.Pool -> *PoolProxy)
- JWT functions now accept context.Context instead of using context.Background()
- Handler DB calls route through PoolProxy for per-test transaction support
- Fixture/helper/testdb functions accept Querier interface for decoupling
- Query ordering fixed in bookings handlers: COUNT after data query to avoid pgx conn busy
- Time truncation fixed: time.Date instead of Truncate(24*time.Hour) for week start calc
- testmain_test.go files updated with SeedBaseline and NewPoolProxy

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-21 19:28:54 +01:00
popertotsandSisyphus 1cf7083bcc feat(backend): add today handler tests
Add comprehensive test suite for today package handlers.

- Add tests for current/next appointment, today appointments, and pending approvals
- Uses testutils.SetupTestDB for isolated test database
- Follows established test patterns in the codebase

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-20 16:59:14 +01:00
popertotsandSisyphus 9f9899354c feat(backend): add time blocker management and name history cleanup
Add name history cleanup to the scheduling pipeline and improve time blocker tests.

- Call CleanupOldNameHistory from GetAvailableHours to periodically purge
  old name_history entries (6+ months)
- Add time_blockers_test.go with comprehensive test coverage
- Update time-blockers.go with name_history cleanup logic

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-20 16:58:59 +01:00
popertotsandSisyphus fb910bf60d feat(backend): migrate notification IDs from int to string and update cursor format
Change notification ID type from int to string (CHAR(12)) to match the schema migration.

- Update AdminNotification.ID field to string
- Change cursor format from int-based to string-based for pagination
- Use validators.IsValidID instead of strconv.Atoi for notification ID validation
- Update cursor format to use RFC3339Nano for precision

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-20 16:58:51 +01:00
popertotsandSisyphus 0beaa6e117 feat(backend): add referral discount preview and transactional campaign safety
Add referral discount to payment preview for users with unused referral discounts.

- Check referral_discounts table for unused discounts in calculateDiscountPreview
- Wrap campaign discount application in a proper database transaction
- Apply eligibility guard for 2nd+ payments to prevent duplicate discount application

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-06-20 16:58:46 +01:00