monoscope/test/integration/Web
Anthony Alaribe 64b3a8bc88
refactor: migrate from pg-transact to effectful-postgresql to support postgres open telemetry instrumentation (#236)
* refactor: migrate from pg-transact to effectful-postgresql

Replace pg-transact and pg-transact-effectful with effectful-postgresql for database operations. Key changes: replace DB effect with WithConnection, remove dbtToEff wrappers, use direct PG.query/PG.execute calls, update runDB to runWithConnectionPool, keep pg-entity for query building, add IOE constraint alongside WithConnection where needed.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

* Auto-format code with fourmolu

* chore: use effectful-postgresql fork with OpenTelemetry support

Switch to tonyalaribe/effectful-postgresql fork (instrument-pg branch) and
enable the +enable-otel flag for OpenTelemetry instrumentation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

* fix: improve connection usage and error handling in BackgroundJobs

- Use PG.execute directly instead of multiple withConnection calls for
  CleanupDemoProject (more efficient connection usage)
- Handle missing project gracefully in ATRuntimeException processing
  instead of crashing with error
- Clean up unused imports (PGS, withConnection)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

* fix: correct effectful-postgresql subdir path

🤖 Generated with [Claude Code](https://claude.com/claude-code)

* fix: add proper error handling and logging for critical operations

- Log advisory lock release failures instead of silently ignoring
- Log when error update doesn't match any span (potential data issue)
- Log when span hash update count mismatches expected (data integrity)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

* Auto-format code with fourmolu

* refactor: simplify single-row query handling in BackgroundJobs

* refactor: return lists from model query functions instead of Vectors

PostgreSQL-simple returns lists naturally, so wrapping results with V.fromList was wasteful. Model query functions now return lists directly, with Vector conversion happening at call sites that actually need Vectors.

* Auto-format code with fourmolu

* perf: fix N+1 query pattern and improve advisory lock handling

- Replace individual UPDATE queries in forM_ loop with batched UPDATE
  using SQL unnest to reduce O(n) DB round-trips to O(1)
- Add 5-minute statement timeout to advisory lock to prevent hangs
- Add timeout reset in finally block for cleanup
- Improve comments explaining session-level lock auto-release behavior

* refactor: replace verbose Only unwrapping with coerce

- Use coerce @[Only T] @[T] instead of map (\(Only x) -> x)
- Use coerce @(Maybe (Only T)) @(Maybe T) instead of fmap (\(Only x) -> x)
- Update GenerateOtelFacetsBatch to use Projects.ProjectId instead of Text

* Auto-format code with fourmolu

* fix: advisory lock release and remove unnecessary vector conversion

- Use query instead of execute for pg_advisory_unlock (SELECT returns result)
- Add validation for unexpected unlock results
- Remove unnecessary V.fromList/V.toList round-trip in runHourlyJob

* refactor: simplify COUNT(*) query result handling

Use inline maybe/listToMaybe instead of case expression for cleaner code.

* Auto-format code with fourmolu

* refactor: use catch instead of try/case for advisory lock cleanup

Cleaner error handling with catch pattern instead of explicit try + case Left/Right.

* Auto-format code with fourmolu

* perf: use V.mapMaybe and V.unzip3 to avoid list conversions

Direct Vector operations for batch error updates instead of
list mapMaybe + V.fromList.

* refactor: introduce DB type alias and switch to pg-transact

* Auto-format code with fourmolu

* fix errors in specs

* fix: remove duplicate import in Dashboards.hs

* fix: resolve integration test failures

- BusinessFlowsSpec: fix column names for apis.subscriptions table

- TestUtils: add test user as admin to nil UUID project

- System/Types: increase static UUID pool to prevent collisions

- AnomaliesSpec: fix test assertions for correct filter views

* fix aroundAll

* fix: resolve integration test failures

- Fix insertProjectMembers to handle empty list (prevents 'no rows supplied' error)

- Fix DashboardsSpec UUID collisions by grouping creations and adding cleanup

- Fix ManageMembersSpec: correct userID to UUID 1, update expected member count and email

- Fix ProjectsSpec: update expected project count to include demo project

* remove PG_EFFECT_MIGRATION.md

* fix: use unique team handles in bulk add teams test to avoid conflicts

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
History 2025-12-22 22:32:43 +01:00
..
ClientMetadataSpec.hs refactor: migrate from pg-transact to effectful-postgresql to support postgres open telemetry instrumentation (#236) 2025-12-22 22:32:43 +01:00