From 4346e726b3ea517213c837c145f559bb80b95bf8 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sun, 11 Oct 2026 04:39:26 +0000 Subject: [PATCH 1/4] perf(database): Remove the redundant SQLite identity index The integer primary key already guarantees identity uniqueness, so new databases can avoid a separate identity index. Keep existing tables intact and retain AUTOINCREMENT so deleted identities are not reused. --- src/database.gleam | 2 +- test/mayu_test.gleam | 52 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/src/database.gleam b/src/database.gleam index 0d4aebc..20fa83a 100644 --- a/src/database.gleam +++ b/src/database.gleam @@ -40,7 +40,7 @@ fn setup_sqlite(connection) { let assert Ok(_) = sqlight.exec( "create table if not exists tb_count ( - id integer primary key autoincrement not null unique, + id integer primary key autoincrement not null, name text not null unique, num int not null default (0) ) strict;", diff --git a/test/mayu_test.gleam b/test/mayu_test.gleam index 9f55c5e..51d3da1 100644 --- a/test/mayu_test.gleam +++ b/test/mayu_test.gleam @@ -41,10 +41,62 @@ pub fn setup_migrates_legacy_moe_counter_table_test() { let assert Ok(counter) = database.get_counter(database.Sqlite(connection), "legacy") + let assert Ok(index_counts) = + sqlight.query( + "select count(*) from pragma_index_list('tb_count');", + on: connection, + with: [], + expecting: decode.at([0], decode.int), + ) counter.num |> should.equal(42) counter.created_at |> should.equal("") counter.updated_at |> should.not_equal("") + index_counts |> should.equal([2]) +} + +pub fn setup_preserves_sqlite_identity_and_name_constraints_test() { + use connection <- sqlight.with_connection(":memory:") + + database.setup(database.Sqlite(connection)) + database.setup(database.Sqlite(connection)) + + let assert Ok(indexed_columns) = + sqlight.query( + "select name from pragma_index_info('sqlite_autoindex_tb_count_1');", + on: connection, + with: [], + expecting: decode.at([0], decode.string), + ) + let assert Ok(_) = + sqlight.exec( + "insert into tb_count (id, name) values (128, 'first');", + connection, + ) + let assert Error(_) = + sqlight.exec( + "insert into tb_count (id, name) values (128, 'duplicate-id');", + connection, + ) + let assert Error(_) = + sqlight.exec("insert into tb_count (name) values ('first');", connection) + let assert Ok(_) = + sqlight.exec( + "delete from tb_count where name = 'first'; + insert into tb_count (name) values ('second');", + connection, + ) + let assert Ok(identities) = + sqlight.query( + "select id from tb_count where name = 'second';", + on: connection, + with: [], + expecting: decode.at([0], decode.int), + ) + + indexed_columns |> should.equal(["name"]) + identities |> should.equal([129]) + remaining_names(connection) |> should.equal(["second"]) } pub fn prune_removes_only_idle_low_count_test() { From 6eafb9777b4427ca1dd68bbdbbe775be66ab0f38 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sun, 11 Oct 2026 04:39:32 +0000 Subject: [PATCH 2/4] perf(docker): Reuse the theme layer after source changes --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 4b31fa1..09494b3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,12 +27,13 @@ COPY gleam.toml manifest.toml ./ RUN gleam deps download -COPY src/ ./src/ COPY themes/ ./themes/ COPY scripts/ ./scripts/ RUN ./scripts/sync-themes.sh +COPY src/ ./src/ + RUN gleam export erlang-shipment FROM erlang:27-alpine From ec924d3d82939647d560e3a04940d4a4d1fc3bb4 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sun, 11 Oct 2026 04:39:44 +0000 Subject: [PATCH 3/4] perf(homepage): Avoid unused fonts and hidden mascot loading --- index.html | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/index.html b/index.html index 73da101..f4d8c8d 100644 --- a/index.html +++ b/index.html @@ -8,8 +8,7 @@