diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 525c94f..621fd4b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,12 +1,14 @@ name: CI on: push: - branches-ignore: - - 'generated' - - 'codegen/**' - - 'integrated/**' - - 'stl-preview-head/**' - - 'stl-preview-base/**' + branches: + - '**' + - '!integrated/**' + - '!stl-preview-head/**' + - '!stl-preview-base/**' + - '!generated' + - '!codegen/**' + - 'codegen/stl/**' pull_request: branches-ignore: - 'stl-preview-head/**' diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 3d2ac0b..5547f83 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0" + ".": "0.1.1" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index f7634d8..1b8e789 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # Changelog +## 0.1.1 (2026-03-18) + +Full Changelog: [v0.1.0...v0.1.1](https://github.com/beeper/desktop-api-sql/compare/v0.1.0...v0.1.1) + +### Chores + +* **internal:** codegen related update ([91994fa](https://github.com/beeper/desktop-api-sql/commit/91994fa8b9e406c674d5245f2da123608e87046b)) +* **internal:** support env vars in `./scripts/repl` ([9183ad1](https://github.com/beeper/desktop-api-sql/commit/9183ad1d77206204a8650471616d1f97b817f024)) +* **internal:** tweak CI branches ([2db5518](https://github.com/beeper/desktop-api-sql/commit/2db5518d6ac525ccd1d753e271f6adcde42398bf)) + + +### Documentation + +* explain caching ([d84f8a5](https://github.com/beeper/desktop-api-sql/commit/d84f8a50545721a86b7ea48a8af34bd588961c54)) + ## 0.1.0 (2026-03-13) Full Changelog: [v0.0.1...v0.1.0](https://github.com/beeper/desktop-api-sql/compare/v0.0.1...v0.1.0) diff --git a/README.md b/README.md index 0544b3f..e2d467b 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,27 @@ LIMIT 200; > removed, then PostgreSQL may not [push down the condition](https://wiki.postgresql.org/wiki/Inlining_of_SQL_functions), > causing all pages to be requested and buffered. +## Caching + +Sending requests to the Beeper Desktop API for every SQL query can be slow. Combine [materialized views](https://www.postgresql.org/docs/current/rules-materializedviews.html) with [`pg_cron`](https://github.com/citusdata/pg_cron) for scheduled data pulls: + +```sql +CREATE MATERIALIZED VIEW beeper_desktop_api_messages AS +SELECT * +FROM beeper_desktop_api_messages.search( + account_ids := ARRAY['local-telegram_ba_QFrb5lrLPhO3OT5MFBeTWv0x4BI'], + "limit" := 10, + query := 'deployment' +); + +-- Refresh the view every 4 hours. +SELECT cron.schedule( + 'refresh-beeper-desktop-api-messages', + '0 */4 * * *', + 'REFRESH MATERIALIZED VIEW CONCURRENTLY beeper_desktop_api_messages' +); +``` + ## Troubleshooting ### Installation diff --git a/scripts/repl b/scripts/repl index 21d1eab..679bf51 100755 --- a/scripts/repl +++ b/scripts/repl @@ -1,5 +1,10 @@ #!/usr/bin/env bash +if [ -z "$BEEPER_ACCESS_TOKEN" ]; then + echo 'ERROR: BEEPER_ACCESS_TOKEN environment variable is required but not set' + exit 1 +fi + echo "==> Detecting PostgreSQL Python executable" PYTHON_EXECUTABLE_PATH=$(pg_config --configure | grep -o "PYTHON=[^ ]*" | cut -d= -f2 | tr -d "'") echo "PostgreSQL uses Python $PYTHON_EXECUTABLE_PATH" @@ -29,8 +34,8 @@ if [ "$PG_MAJOR_VERSION" -ge 18 ]; then done POSTGRES_CONFIG=(-c extension_control_path="$(realpath temp/install/share/postgresql)") else - # In PostgreSQL <18 we cannot point `postgres` to our local extensions directory. So we install directly to - # the system. + # In PostgreSQL <18 we cannot point `postgres` to our local extensions directory. So we install + # directly to the system. sudo make install PG_CONFIG="$(command -v pg_config)" fi @@ -61,10 +66,15 @@ done echo "==> Running setup.sql" psql -d postgres -f test/sql/create_extension.sql +psql -d postgres --variable "value='$BEEPER_ACCESS_TOKEN'" -c 'ALTER DATABASE postgres SET beeper_desktop_api.beeper_access_token = :value;' +if [ -n "$BEEPER_DESKTOP_BASE_URL" ]; then + psql -d postgres --variable "value='$BEEPER_DESKTOP_BASE_URL'" -c 'ALTER DATABASE postgres SET beeper_desktop_api.base_url = :value;' +fi + if command -v pgcli &>/dev/null; then echo "==> Starting pgcli REPL" pgcli postgres else echo "==> Starting psql REPL (TIP: Install pgcli for better autocomplete!)" psql -d postgres -fi +fi \ No newline at end of file diff --git a/uv.lock b/uv.lock index 3e068d8..99ade34 100644 --- a/uv.lock +++ b/uv.lock @@ -103,7 +103,7 @@ wheels = [ [[package]] name = "beeper_desktop_api" -version = "0.0.1" +version = "4.3.0" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "anyio" },