fix: star count increment matches on rkey OR name Star AT-URI subjects contain the record rkey, not the human-readable repo name. The UPDATE query now matches on either so both Tangled (rkey-based) and Cospan (name-based) stars increment correctly.

Author: Aaron Steven White
Commit 8a0beaa68defe6ae3ab9a4047df6de088d4e256a
Parent: b80edca5f1
Structural diff unavailable

These commits were pushed via plain git push, so no pre-parsed schemas are available. Install git-remote-cospan and re-push via panproto:// to see scope-level changes, breaking change detection, and semantic diffs.

brew install panproto/tap/git-remote-cospan
1 file changed +9 -7
@@ -5,18 +5,20 @@ use chrono::{DateTime, Utc};
55 use sqlx::PgPool;
66 
77 /// Increment the star_count on the repo referenced by the AT-URI subject.
8-/// Subject format: at://did/dev.cospan.repo/repo-name
8+/// Subject format: at://did/collection/rkey
9+/// The rkey in the AT-URI may be the repo name OR the record rkey,
10+/// so we match on either.
911 pub async fn increment_repo_star_count(
1012     pool: &PgPool,
1113     repo_did: &str,
12-    repo_name: &str,
14+    repo_rkey: &str,
1315 ) -> Result<(), sqlx::Error> {
1416     sqlx::query(
1517         "UPDATE repos SET star_count = star_count + 1, indexed_at = NOW() \
16-         WHERE did = $1 AND name = $2",
18+         WHERE did = $1 AND (name = $2 OR rkey = $2)",
1719     )
1820     .bind(repo_did)
19-    .bind(repo_name)
21+    .bind(repo_rkey)
2022     .execute(pool)
2123     .await?;
2224     Ok(())
@@ -25,14 +27,14 @@ pub async fn increment_repo_star_count(
2527 pub async fn decrement_repo_star_count(
2628     pool: &PgPool,
2729     repo_did: &str,
28-    repo_name: &str,
30+    repo_rkey: &str,
2931 ) -> Result<(), sqlx::Error> {
3032     sqlx::query(
3133         "UPDATE repos SET star_count = GREATEST(star_count - 1, 0), indexed_at = NOW() \
32-         WHERE did = $1 AND name = $2",
34+         WHERE did = $1 AND (name = $2 OR rkey = $2)",
3335     )
3436     .bind(repo_did)
35-    .bind(repo_name)
37+    .bind(repo_rkey)
3638     .execute(pool)
3739     .await?;
3840     Ok(())
cospan · schematic version control on atproto built on AT Protocol