Compare commits

...

5 Commits

Author SHA1 Message Date
4081600dce Extract rubocop to a separate job in CI 2025-01-23 22:06:24 +01:00
356e799c68 WIP store stats history
Some checks failed
Add copyright notice / copyright_notice (pull_request) Successful in 1m57s
Check usage of free licenses / check-licenses (pull_request) Successful in 3m50s
Run unit tests / unit_tests (pull_request) Successful in 4m33s
Build Nginx-based docker image / build-static-assets (pull_request) Has been cancelled
2025-01-23 21:57:18 +01:00
259d559b71 Enable pgstatements in Postgres 2025-01-22 21:40:08 +01:00
0c5162b326 Install pg_stat_statements extension 2025-01-22 21:29:13 +01:00
598642a0db Use a pghero docker image in the local environment 2025-01-22 21:24:19 +01:00
7 changed files with 72 additions and 11 deletions

View File

@ -24,7 +24,6 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: ruby/setup-ruby@v1.207.0
- run: bundle install
- run: bundle exec rubocop --force-exclusion --parallel
- name: Wait until Postgres is ready to accept connections
run: |
apt-get update && apt-get install -f -y postgresql-client
@ -42,3 +41,12 @@ jobs:
- name: Clean up containers generated by this flow
if: failure()
run: docker ps --filter network=$JOB_CONTAINER_NAME-$GITHUB_JOB-network --filter name=$JOB_CONTAINER_NAME-* --format "{{.ID}}" | xargs docker rm -f
rubocop:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: ruby/setup-ruby@v1.207.0
- run: bundle install
- run: bundle exec rubocop --force-exclusion --parallel

View File

@ -57,16 +57,17 @@ The backend service will seed the database with fake data. It's worth noting tha
The backend, frontend and workers have hot-reloading enabled, so changes made to the codebase should be reflected in the application on the next request.
Once all containers have started, visit http://libre-wedding-planner.app.localhost/default/dashboard to load the application.
Once all containers have started, visit:
- http://libre-wedding-planner.app.localhost/default to load the application.
- http://libre-wedding-planner.app.localhost/letter_opener/ to get a list of emails generated by the application.
- http://pghero.libre-wedding-planner.app.localhost to load the [pghero](https://github.com/ankane/pghero) tool.
## Multitenancy
LibreWeddingPlanner is designed to manage multiple weddings in a single host. All URLs (in the API and the frontend) are scoped under a slug that is unique per wedding. The slug is made of lowercase letters, numbers, and dashes (-).
The development environment is seeded with a wedding whose slug is `default`.
## Email delivery
In the development environment, real emails will not be sent. You can visit http://libre-wedding-planner.app.localhost/letter_opener/ to get a list of emails generated by the application.
## Testing

View File

@ -0,0 +1,5 @@
class EnablePgStatStatements < ActiveRecord::Migration[8.0]
def change
enable_extension 'pg_stat_statements'
end
end

View File

@ -0,0 +1,21 @@
class CreatePgheroStatsTables < ActiveRecord::Migration[8.0]
def up
execute <<~SQL
CREATE TABLE "pghero_query_stats" (
"id" bigserial primary key,
"database" text,
"user" text,
"query" text,
"query_hash" bigint,
"total_time" float,
"calls" bigint,
"captured_at" timestamp
);
CREATE INDEX ON "pghero_query_stats" ("database", "captured_at");
SQL
end
def down
drop_table :pghero_query_stats, if_exists: true, force: :cascade
end
end

18
db/schema.rb generated
View File

@ -1,7 +1,3 @@
# Copyright (C) 2024 Manuel Bustillo
# Copyright (C) 2024-2025 LibreWeddingPlanner contributors
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
@ -14,9 +10,10 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[8.0].define(version: 2024_12_16_231415) do
ActiveRecord::Schema[8.0].define(version: 2025_01_22_204932) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_catalog.plpgsql"
enable_extension "pg_stat_statements"
# Custom types defined in this database.
# Note that some types may not work with other database engines. Be careful if changing database.
@ -71,6 +68,17 @@ ActiveRecord::Schema[8.0].define(version: 2024_12_16_231415) do
t.index ["wedding_id"], name: "index_guests_on_wedding_id"
end
create_table "pghero_query_stats", force: :cascade do |t|
t.text "database"
t.text "user"
t.text "query"
t.bigint "query_hash"
t.float "total_time"
t.bigint "calls"
t.datetime "captured_at", precision: nil
t.index ["database", "captured_at"], name: "pghero_query_stats_database_captured_at_idx"
end
create_table "seats", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.uuid "guest_id", null: false
t.uuid "tables_arrangement_id", null: false

View File

@ -74,10 +74,19 @@ services:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
command: postgres -c shared_preload_libraries='pg_stat_statements' -c pg_stat_statements.track=all
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U postgres']
interval: 10s
timeout: 5s
retries: 5
pghero:
image: ankane/pghero
ports:
- 8080
environment:
DATABASE_URL: postgres://postgres:postgres@db:5432/postgres
depends_on:
db:
condition: service_healthy

View File

@ -23,3 +23,12 @@ server {
}
}
server {
listen 80;
server_name pghero.libre-wedding-planner.app.localhost;
location / {
proxy_pass http://pghero:8080;
proxy_set_header Host $http_host;
}
}