Add profile pin persistence
- SHA
cd0fd7847285aca92728d482988f3f96aa304d5f- Parents
-
042883c - Tree
6230a05
cd0fd78
cd0fd7847285aca92728d482988f3f96aa304d5f042883c
6230a05| Status | File | + | - |
|---|---|---|---|
| M |
internal/admin/sqlc/models.go
|
14 | 0 |
| M |
internal/auth/policy/sqlc/models.go
|
14 | 0 |
| M |
internal/checks/sqlc/models.go
|
14 | 0 |
| M |
internal/issues/sqlc/models.go
|
14 | 0 |
| M |
internal/meta/sqlc/models.go
|
14 | 0 |
| A |
internal/migrationsfs/migrations/0040_profile_pins.sql
|
46 | 0 |
| M |
internal/notif/sqlc/models.go
|
14 | 0 |
| M |
internal/orgs/sqlc/models.go
|
14 | 0 |
| M |
internal/pulls/sqlc/models.go
|
14 | 0 |
| M |
internal/ratelimit/sqlc/models.go
|
14 | 0 |
| M |
internal/repos/queries/repos.sql
|
35 | 0 |
| M |
internal/repos/sqlc/models.go
|
14 | 0 |
| M |
internal/repos/sqlc/querier.go
|
8 | 0 |
| M |
internal/repos/sqlc/repos.sql.go
|
111 | 0 |
| M |
internal/social/sqlc/models.go
|
14 | 0 |
| M |
internal/users/sqlc/models.go
|
14 | 0 |
| M |
internal/webhook/sqlc/models.go
|
14 | 0 |
| M |
internal/worker/sqlc/models.go
|
14 | 0 |
internal/admin/sqlc/models.gomodified@@ -1629,6 +1629,20 @@ type Principal struct { | ||
| 1629 | 1629 | ID int64 |
| 1630 | 1630 | } |
| 1631 | 1631 | |
| 1632 | +type ProfilePin struct { | |
| 1633 | + SetID int64 | |
| 1634 | + RepoID int64 | |
| 1635 | + Position int32 | |
| 1636 | + PinnedAt pgtype.Timestamptz | |
| 1637 | +} | |
| 1638 | + | |
| 1639 | +type ProfilePinSet struct { | |
| 1640 | + ID int64 | |
| 1641 | + OwnerUserID pgtype.Int8 | |
| 1642 | + OwnerOrgID pgtype.Int8 | |
| 1643 | + UpdatedAt pgtype.Timestamptz | |
| 1644 | +} | |
| 1645 | + | |
| 1632 | 1646 | type PullRequest struct { |
| 1633 | 1647 | IssueID int64 |
| 1634 | 1648 | BaseRef string |
internal/auth/policy/sqlc/models.gomodified@@ -1629,6 +1629,20 @@ type Principal struct { | ||
| 1629 | 1629 | ID int64 |
| 1630 | 1630 | } |
| 1631 | 1631 | |
| 1632 | +type ProfilePin struct { | |
| 1633 | + SetID int64 | |
| 1634 | + RepoID int64 | |
| 1635 | + Position int32 | |
| 1636 | + PinnedAt pgtype.Timestamptz | |
| 1637 | +} | |
| 1638 | + | |
| 1639 | +type ProfilePinSet struct { | |
| 1640 | + ID int64 | |
| 1641 | + OwnerUserID pgtype.Int8 | |
| 1642 | + OwnerOrgID pgtype.Int8 | |
| 1643 | + UpdatedAt pgtype.Timestamptz | |
| 1644 | +} | |
| 1645 | + | |
| 1632 | 1646 | type PullRequest struct { |
| 1633 | 1647 | IssueID int64 |
| 1634 | 1648 | BaseRef string |
internal/checks/sqlc/models.gomodified@@ -1629,6 +1629,20 @@ type Principal struct { | ||
| 1629 | 1629 | ID int64 |
| 1630 | 1630 | } |
| 1631 | 1631 | |
| 1632 | +type ProfilePin struct { | |
| 1633 | + SetID int64 | |
| 1634 | + RepoID int64 | |
| 1635 | + Position int32 | |
| 1636 | + PinnedAt pgtype.Timestamptz | |
| 1637 | +} | |
| 1638 | + | |
| 1639 | +type ProfilePinSet struct { | |
| 1640 | + ID int64 | |
| 1641 | + OwnerUserID pgtype.Int8 | |
| 1642 | + OwnerOrgID pgtype.Int8 | |
| 1643 | + UpdatedAt pgtype.Timestamptz | |
| 1644 | +} | |
| 1645 | + | |
| 1632 | 1646 | type PullRequest struct { |
| 1633 | 1647 | IssueID int64 |
| 1634 | 1648 | BaseRef string |
internal/issues/sqlc/models.gomodified@@ -1629,6 +1629,20 @@ type Principal struct { | ||
| 1629 | 1629 | ID int64 |
| 1630 | 1630 | } |
| 1631 | 1631 | |
| 1632 | +type ProfilePin struct { | |
| 1633 | + SetID int64 | |
| 1634 | + RepoID int64 | |
| 1635 | + Position int32 | |
| 1636 | + PinnedAt pgtype.Timestamptz | |
| 1637 | +} | |
| 1638 | + | |
| 1639 | +type ProfilePinSet struct { | |
| 1640 | + ID int64 | |
| 1641 | + OwnerUserID pgtype.Int8 | |
| 1642 | + OwnerOrgID pgtype.Int8 | |
| 1643 | + UpdatedAt pgtype.Timestamptz | |
| 1644 | +} | |
| 1645 | + | |
| 1632 | 1646 | type PullRequest struct { |
| 1633 | 1647 | IssueID int64 |
| 1634 | 1648 | BaseRef string |
internal/meta/sqlc/models.gomodified@@ -1629,6 +1629,20 @@ type Principal struct { | ||
| 1629 | 1629 | ID int64 |
| 1630 | 1630 | } |
| 1631 | 1631 | |
| 1632 | +type ProfilePin struct { | |
| 1633 | + SetID int64 | |
| 1634 | + RepoID int64 | |
| 1635 | + Position int32 | |
| 1636 | + PinnedAt pgtype.Timestamptz | |
| 1637 | +} | |
| 1638 | + | |
| 1639 | +type ProfilePinSet struct { | |
| 1640 | + ID int64 | |
| 1641 | + OwnerUserID pgtype.Int8 | |
| 1642 | + OwnerOrgID pgtype.Int8 | |
| 1643 | + UpdatedAt pgtype.Timestamptz | |
| 1644 | +} | |
| 1645 | + | |
| 1632 | 1646 | type PullRequest struct { |
| 1633 | 1647 | IssueID int64 |
| 1634 | 1648 | BaseRef string |
internal/migrationsfs/migrations/0040_profile_pins.sqladded@@ -0,0 +1,46 @@ | ||
| 1 | +-- SPDX-License-Identifier: AGPL-3.0-or-later | |
| 2 | +-- | |
| 3 | +-- Profile and organization pinned repositories. | |
| 4 | +-- | |
| 5 | +-- A pin set records that the owner has customized their pinned | |
| 6 | +-- repositories. The separate row lets us distinguish "never customized" | |
| 7 | +-- from "customized to zero pins" while keeping the ordered pins table | |
| 8 | +-- normalized and easy to replace transactionally. | |
| 9 | + | |
| 10 | +-- +goose Up | |
| 11 | +CREATE TABLE profile_pin_sets ( | |
| 12 | + id bigserial PRIMARY KEY, | |
| 13 | + owner_user_id bigint REFERENCES users(id) ON DELETE CASCADE, | |
| 14 | + owner_org_id bigint REFERENCES orgs(id) ON DELETE CASCADE, | |
| 15 | + updated_at timestamptz NOT NULL DEFAULT now(), | |
| 16 | + | |
| 17 | + CONSTRAINT profile_pin_sets_owner_xor CHECK ( | |
| 18 | + (owner_user_id IS NOT NULL AND owner_org_id IS NULL) | |
| 19 | + OR (owner_user_id IS NULL AND owner_org_id IS NOT NULL) | |
| 20 | + ) | |
| 21 | +); | |
| 22 | + | |
| 23 | +CREATE UNIQUE INDEX profile_pin_sets_owner_user_uq | |
| 24 | + ON profile_pin_sets (owner_user_id) | |
| 25 | + WHERE owner_user_id IS NOT NULL; | |
| 26 | + | |
| 27 | +CREATE UNIQUE INDEX profile_pin_sets_owner_org_uq | |
| 28 | + ON profile_pin_sets (owner_org_id) | |
| 29 | + WHERE owner_org_id IS NOT NULL; | |
| 30 | + | |
| 31 | +CREATE TABLE profile_pins ( | |
| 32 | + set_id bigint NOT NULL REFERENCES profile_pin_sets(id) ON DELETE CASCADE, | |
| 33 | + repo_id bigint NOT NULL REFERENCES repos(id) ON DELETE CASCADE, | |
| 34 | + position integer NOT NULL, | |
| 35 | + pinned_at timestamptz NOT NULL DEFAULT now(), | |
| 36 | + | |
| 37 | + PRIMARY KEY (set_id, repo_id), | |
| 38 | + CONSTRAINT profile_pins_position_range CHECK (position BETWEEN 1 AND 6), | |
| 39 | + CONSTRAINT profile_pins_set_position_uq UNIQUE (set_id, position) | |
| 40 | +); | |
| 41 | + | |
| 42 | +CREATE INDEX profile_pins_repo_idx ON profile_pins (repo_id); | |
| 43 | + | |
| 44 | +-- +goose Down | |
| 45 | +DROP TABLE IF EXISTS profile_pins; | |
| 46 | +DROP TABLE IF EXISTS profile_pin_sets; | |
internal/notif/sqlc/models.gomodified@@ -1629,6 +1629,20 @@ type Principal struct { | ||
| 1629 | 1629 | ID int64 |
| 1630 | 1630 | } |
| 1631 | 1631 | |
| 1632 | +type ProfilePin struct { | |
| 1633 | + SetID int64 | |
| 1634 | + RepoID int64 | |
| 1635 | + Position int32 | |
| 1636 | + PinnedAt pgtype.Timestamptz | |
| 1637 | +} | |
| 1638 | + | |
| 1639 | +type ProfilePinSet struct { | |
| 1640 | + ID int64 | |
| 1641 | + OwnerUserID pgtype.Int8 | |
| 1642 | + OwnerOrgID pgtype.Int8 | |
| 1643 | + UpdatedAt pgtype.Timestamptz | |
| 1644 | +} | |
| 1645 | + | |
| 1632 | 1646 | type PullRequest struct { |
| 1633 | 1647 | IssueID int64 |
| 1634 | 1648 | BaseRef string |
internal/orgs/sqlc/models.gomodified@@ -1629,6 +1629,20 @@ type Principal struct { | ||
| 1629 | 1629 | ID int64 |
| 1630 | 1630 | } |
| 1631 | 1631 | |
| 1632 | +type ProfilePin struct { | |
| 1633 | + SetID int64 | |
| 1634 | + RepoID int64 | |
| 1635 | + Position int32 | |
| 1636 | + PinnedAt pgtype.Timestamptz | |
| 1637 | +} | |
| 1638 | + | |
| 1639 | +type ProfilePinSet struct { | |
| 1640 | + ID int64 | |
| 1641 | + OwnerUserID pgtype.Int8 | |
| 1642 | + OwnerOrgID pgtype.Int8 | |
| 1643 | + UpdatedAt pgtype.Timestamptz | |
| 1644 | +} | |
| 1645 | + | |
| 1632 | 1646 | type PullRequest struct { |
| 1633 | 1647 | IssueID int64 |
| 1634 | 1648 | BaseRef string |
internal/pulls/sqlc/models.gomodified@@ -1629,6 +1629,20 @@ type Principal struct { | ||
| 1629 | 1629 | ID int64 |
| 1630 | 1630 | } |
| 1631 | 1631 | |
| 1632 | +type ProfilePin struct { | |
| 1633 | + SetID int64 | |
| 1634 | + RepoID int64 | |
| 1635 | + Position int32 | |
| 1636 | + PinnedAt pgtype.Timestamptz | |
| 1637 | +} | |
| 1638 | + | |
| 1639 | +type ProfilePinSet struct { | |
| 1640 | + ID int64 | |
| 1641 | + OwnerUserID pgtype.Int8 | |
| 1642 | + OwnerOrgID pgtype.Int8 | |
| 1643 | + UpdatedAt pgtype.Timestamptz | |
| 1644 | +} | |
| 1645 | + | |
| 1632 | 1646 | type PullRequest struct { |
| 1633 | 1647 | IssueID int64 |
| 1634 | 1648 | BaseRef string |
internal/ratelimit/sqlc/models.gomodified@@ -1629,6 +1629,20 @@ type Principal struct { | ||
| 1629 | 1629 | ID int64 |
| 1630 | 1630 | } |
| 1631 | 1631 | |
| 1632 | +type ProfilePin struct { | |
| 1633 | + SetID int64 | |
| 1634 | + RepoID int64 | |
| 1635 | + Position int32 | |
| 1636 | + PinnedAt pgtype.Timestamptz | |
| 1637 | +} | |
| 1638 | + | |
| 1639 | +type ProfilePinSet struct { | |
| 1640 | + ID int64 | |
| 1641 | + OwnerUserID pgtype.Int8 | |
| 1642 | + OwnerOrgID pgtype.Int8 | |
| 1643 | + UpdatedAt pgtype.Timestamptz | |
| 1644 | +} | |
| 1645 | + | |
| 1632 | 1646 | type PullRequest struct { |
| 1633 | 1647 | IssueID int64 |
| 1634 | 1648 | BaseRef string |
internal/repos/queries/repos.sqlmodified@@ -125,6 +125,41 @@ UPDATE repos | ||
| 125 | 125 | -- name: ListRepoTopics :many |
| 126 | 126 | SELECT topic FROM repo_topics WHERE repo_id = $1 ORDER BY topic ASC; |
| 127 | 127 | |
| 128 | +-- ─── profile/org pinned repositories ─────────────────────────────── | |
| 129 | + | |
| 130 | +-- name: GetProfilePinSetForUser :one | |
| 131 | +SELECT id FROM profile_pin_sets WHERE owner_user_id = $1; | |
| 132 | + | |
| 133 | +-- name: GetProfilePinSetForOrg :one | |
| 134 | +SELECT id FROM profile_pin_sets WHERE owner_org_id = $1; | |
| 135 | + | |
| 136 | +-- name: UpsertProfilePinSetForUser :one | |
| 137 | +INSERT INTO profile_pin_sets (owner_user_id) | |
| 138 | +VALUES ($1) | |
| 139 | +ON CONFLICT (owner_user_id) WHERE owner_user_id IS NOT NULL | |
| 140 | +DO UPDATE SET updated_at = now() | |
| 141 | +RETURNING id; | |
| 142 | + | |
| 143 | +-- name: UpsertProfilePinSetForOrg :one | |
| 144 | +INSERT INTO profile_pin_sets (owner_org_id) | |
| 145 | +VALUES ($1) | |
| 146 | +ON CONFLICT (owner_org_id) WHERE owner_org_id IS NOT NULL | |
| 147 | +DO UPDATE SET updated_at = now() | |
| 148 | +RETURNING id; | |
| 149 | + | |
| 150 | +-- name: ListProfilePinsForSet :many | |
| 151 | +SELECT repo_id, position | |
| 152 | +FROM profile_pins | |
| 153 | +WHERE set_id = $1 | |
| 154 | +ORDER BY position ASC; | |
| 155 | + | |
| 156 | +-- name: DeleteProfilePinsForSet :exec | |
| 157 | +DELETE FROM profile_pins WHERE set_id = $1; | |
| 158 | + | |
| 159 | +-- name: InsertProfilePin :exec | |
| 160 | +INSERT INTO profile_pins (set_id, repo_id, position) | |
| 161 | +VALUES ($1, $2, $3); | |
| 162 | + | |
| 128 | 163 | -- name: ReplaceRepoTopics :exec |
| 129 | 164 | -- Atomic full-replace: callers compose the new topic set in Go, |
| 130 | 165 | -- then replace the existing rows in one tx (DELETE + INSERT). The |
internal/repos/sqlc/models.gomodified@@ -1629,6 +1629,20 @@ type Principal struct { | ||
| 1629 | 1629 | ID int64 |
| 1630 | 1630 | } |
| 1631 | 1631 | |
| 1632 | +type ProfilePin struct { | |
| 1633 | + SetID int64 | |
| 1634 | + RepoID int64 | |
| 1635 | + Position int32 | |
| 1636 | + PinnedAt pgtype.Timestamptz | |
| 1637 | +} | |
| 1638 | + | |
| 1639 | +type ProfilePinSet struct { | |
| 1640 | + ID int64 | |
| 1641 | + OwnerUserID pgtype.Int8 | |
| 1642 | + OwnerOrgID pgtype.Int8 | |
| 1643 | + UpdatedAt pgtype.Timestamptz | |
| 1644 | +} | |
| 1645 | + | |
| 1632 | 1646 | type PullRequest struct { |
| 1633 | 1647 | IssueID int64 |
| 1634 | 1648 | BaseRef string |
internal/repos/sqlc/querier.gomodified@@ -31,6 +31,7 @@ type Querier interface { | ||
| 31 | 31 | CreateRepo(ctx context.Context, db DBTX, arg CreateRepoParams) (Repo, error) |
| 32 | 32 | DeclineTransferRequest(ctx context.Context, db DBTX, id int64) error |
| 33 | 33 | DeleteBranchProtectionRule(ctx context.Context, db DBTX, id int64) error |
| 34 | + DeleteProfilePinsForSet(ctx context.Context, db DBTX, setID int64) error | |
| 34 | 35 | // Used by the rename compensator: drop a single redirect row when |
| 35 | 36 | // the rename has to be rolled back due to a filesystem failure. We |
| 36 | 37 | // avoided raw SQL here at the audit's request (S00-S25, M). |
@@ -45,6 +46,9 @@ type Querier interface { | ||
| 45 | 46 | // offers past their expires_at to the expired terminal state. |
| 46 | 47 | ExpirePendingTransfers(ctx context.Context, db DBTX) (int64, error) |
| 47 | 48 | GetBranchProtectionRule(ctx context.Context, db DBTX, id int64) (BranchProtectionRule, error) |
| 49 | + GetProfilePinSetForOrg(ctx context.Context, db DBTX, ownerOrgID pgtype.Int8) (int64, error) | |
| 50 | + // ─── profile/org pinned repositories ─────────────────────────────── | |
| 51 | + GetProfilePinSetForUser(ctx context.Context, db DBTX, ownerUserID pgtype.Int8) (int64, error) | |
| 48 | 52 | GetRepoByID(ctx context.Context, db DBTX, id int64) (Repo, error) |
| 49 | 53 | // S30: org-owner mirror of GetRepoByOwnerUserAndName. The (owner_org_id, |
| 50 | 54 | // name) partial unique index from 0017 backs this lookup with the same |
@@ -57,6 +61,7 @@ type Querier interface { | ||
| 57 | 61 | GetRepoOwnerUsernameByID(ctx context.Context, db DBTX, id int64) (GetRepoOwnerUsernameByIDRow, error) |
| 58 | 62 | GetTransferRequest(ctx context.Context, db DBTX, id int64) (RepoTransferRequest, error) |
| 59 | 63 | HardDeleteRepo(ctx context.Context, db DBTX, id int64) error |
| 64 | + InsertProfilePin(ctx context.Context, db DBTX, arg InsertProfilePinParams) error | |
| 60 | 65 | // ─── redirects ───────────────────────────────────────────────────────── |
| 61 | 66 | // Both old-owner FKs are nullable; pass exactly one. The CHECK |
| 62 | 67 | // constraint on the table enforces the xor shape. |
@@ -79,6 +84,7 @@ type Querier interface { | ||
| 79 | 84 | ListForksOfRepoForRepack(ctx context.Context, db DBTX, forkOfRepoID pgtype.Int8) ([]ListForksOfRepoForRepackRow, error) |
| 80 | 85 | // Inbox view: pending offers a user can act on. |
| 81 | 86 | ListPendingTransfersForUser(ctx context.Context, db DBTX, toPrincipalID int64) ([]RepoTransferRequest, error) |
| 87 | + ListProfilePinsForSet(ctx context.Context, db DBTX, setID int64) ([]ListProfilePinsForSetRow, error) | |
| 82 | 88 | // ─── soft-delete sweep query ─────────────────────────────────────────── |
| 83 | 89 | // The repo:hard_delete enqueuer queries this to find rows ready for |
| 84 | 90 | // destruction. The 7-day grace is hard-coded here; if we add a config |
@@ -158,6 +164,8 @@ type Querier interface { | ||
| 158 | 164 | UpdateRepoGeneralSettings(ctx context.Context, db DBTX, arg UpdateRepoGeneralSettingsParams) error |
| 159 | 165 | UpdateRepoMergeSettings(ctx context.Context, db DBTX, arg UpdateRepoMergeSettingsParams) error |
| 160 | 166 | UpsertBranchProtectionRule(ctx context.Context, db DBTX, arg UpsertBranchProtectionRuleParams) (int64, error) |
| 167 | + UpsertProfilePinSetForOrg(ctx context.Context, db DBTX, ownerOrgID pgtype.Int8) (int64, error) | |
| 168 | + UpsertProfilePinSetForUser(ctx context.Context, db DBTX, ownerUserID pgtype.Int8) (int64, error) | |
| 161 | 169 | } |
| 162 | 170 | |
| 163 | 171 | var _ Querier = (*Queries)(nil) |
internal/repos/sqlc/repos.sql.gomodified@@ -185,6 +185,15 @@ func (q *Queries) CreateRepo(ctx context.Context, db DBTX, arg CreateRepoParams) | ||
| 185 | 185 | return i, err |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | +const deleteProfilePinsForSet = `-- name: DeleteProfilePinsForSet :exec | |
| 189 | +DELETE FROM profile_pins WHERE set_id = $1 | |
| 190 | +` | |
| 191 | + | |
| 192 | +func (q *Queries) DeleteProfilePinsForSet(ctx context.Context, db DBTX, setID int64) error { | |
| 193 | + _, err := db.Exec(ctx, deleteProfilePinsForSet, setID) | |
| 194 | + return err | |
| 195 | +} | |
| 196 | + | |
| 188 | 197 | const existsRepoForOwnerOrg = `-- name: ExistsRepoForOwnerOrg :one |
| 189 | 198 | SELECT EXISTS( |
| 190 | 199 | SELECT 1 FROM repos |
@@ -223,6 +232,30 @@ func (q *Queries) ExistsRepoForOwnerUser(ctx context.Context, db DBTX, arg Exist | ||
| 223 | 232 | return exists, err |
| 224 | 233 | } |
| 225 | 234 | |
| 235 | +const getProfilePinSetForOrg = `-- name: GetProfilePinSetForOrg :one | |
| 236 | +SELECT id FROM profile_pin_sets WHERE owner_org_id = $1 | |
| 237 | +` | |
| 238 | + | |
| 239 | +func (q *Queries) GetProfilePinSetForOrg(ctx context.Context, db DBTX, ownerOrgID pgtype.Int8) (int64, error) { | |
| 240 | + row := db.QueryRow(ctx, getProfilePinSetForOrg, ownerOrgID) | |
| 241 | + var id int64 | |
| 242 | + err := row.Scan(&id) | |
| 243 | + return id, err | |
| 244 | +} | |
| 245 | + | |
| 246 | +const getProfilePinSetForUser = `-- name: GetProfilePinSetForUser :one | |
| 247 | + | |
| 248 | +SELECT id FROM profile_pin_sets WHERE owner_user_id = $1 | |
| 249 | +` | |
| 250 | + | |
| 251 | +// ─── profile/org pinned repositories ─────────────────────────────── | |
| 252 | +func (q *Queries) GetProfilePinSetForUser(ctx context.Context, db DBTX, ownerUserID pgtype.Int8) (int64, error) { | |
| 253 | + row := db.QueryRow(ctx, getProfilePinSetForUser, ownerUserID) | |
| 254 | + var id int64 | |
| 255 | + err := row.Scan(&id) | |
| 256 | + return id, err | |
| 257 | +} | |
| 258 | + | |
| 226 | 259 | const getRepoByID = `-- name: GetRepoByID :one |
| 227 | 260 | SELECT id, owner_user_id, owner_org_id, name, description, visibility, |
| 228 | 261 | default_branch, is_archived, archived_at, deleted_at, |
@@ -402,6 +435,22 @@ func (q *Queries) GetRepoOwnerUsernameByID(ctx context.Context, db DBTX, id int6 | ||
| 402 | 435 | return i, err |
| 403 | 436 | } |
| 404 | 437 | |
| 438 | +const insertProfilePin = `-- name: InsertProfilePin :exec | |
| 439 | +INSERT INTO profile_pins (set_id, repo_id, position) | |
| 440 | +VALUES ($1, $2, $3) | |
| 441 | +` | |
| 442 | + | |
| 443 | +type InsertProfilePinParams struct { | |
| 444 | + SetID int64 | |
| 445 | + RepoID int64 | |
| 446 | + Position int32 | |
| 447 | +} | |
| 448 | + | |
| 449 | +func (q *Queries) InsertProfilePin(ctx context.Context, db DBTX, arg InsertProfilePinParams) error { | |
| 450 | + _, err := db.Exec(ctx, insertProfilePin, arg.SetID, arg.RepoID, arg.Position) | |
| 451 | + return err | |
| 452 | +} | |
| 453 | + | |
| 405 | 454 | const insertRepoTopic = `-- name: InsertRepoTopic :exec |
| 406 | 455 | INSERT INTO repo_topics (repo_id, topic) |
| 407 | 456 | VALUES ($1, $2) |
@@ -559,6 +608,38 @@ func (q *Queries) ListForksOfRepoForRepack(ctx context.Context, db DBTX, forkOfR | ||
| 559 | 608 | return items, nil |
| 560 | 609 | } |
| 561 | 610 | |
| 611 | +const listProfilePinsForSet = `-- name: ListProfilePinsForSet :many | |
| 612 | +SELECT repo_id, position | |
| 613 | +FROM profile_pins | |
| 614 | +WHERE set_id = $1 | |
| 615 | +ORDER BY position ASC | |
| 616 | +` | |
| 617 | + | |
| 618 | +type ListProfilePinsForSetRow struct { | |
| 619 | + RepoID int64 | |
| 620 | + Position int32 | |
| 621 | +} | |
| 622 | + | |
| 623 | +func (q *Queries) ListProfilePinsForSet(ctx context.Context, db DBTX, setID int64) ([]ListProfilePinsForSetRow, error) { | |
| 624 | + rows, err := db.Query(ctx, listProfilePinsForSet, setID) | |
| 625 | + if err != nil { | |
| 626 | + return nil, err | |
| 627 | + } | |
| 628 | + defer rows.Close() | |
| 629 | + items := []ListProfilePinsForSetRow{} | |
| 630 | + for rows.Next() { | |
| 631 | + var i ListProfilePinsForSetRow | |
| 632 | + if err := rows.Scan(&i.RepoID, &i.Position); err != nil { | |
| 633 | + return nil, err | |
| 634 | + } | |
| 635 | + items = append(items, i) | |
| 636 | + } | |
| 637 | + if err := rows.Err(); err != nil { | |
| 638 | + return nil, err | |
| 639 | + } | |
| 640 | + return items, nil | |
| 641 | +} | |
| 642 | + | |
| 562 | 643 | const listRepoTopics = `-- name: ListRepoTopics :many |
| 563 | 644 | |
| 564 | 645 | SELECT topic FROM repo_topics WHERE repo_id = $1 ORDER BY topic ASC |
@@ -900,3 +981,33 @@ func (q *Queries) UpdateRepoMergeSettings(ctx context.Context, db DBTX, arg Upda | ||
| 900 | 981 | ) |
| 901 | 982 | return err |
| 902 | 983 | } |
| 984 | + | |
| 985 | +const upsertProfilePinSetForOrg = `-- name: UpsertProfilePinSetForOrg :one | |
| 986 | +INSERT INTO profile_pin_sets (owner_org_id) | |
| 987 | +VALUES ($1) | |
| 988 | +ON CONFLICT (owner_org_id) WHERE owner_org_id IS NOT NULL | |
| 989 | +DO UPDATE SET updated_at = now() | |
| 990 | +RETURNING id | |
| 991 | +` | |
| 992 | + | |
| 993 | +func (q *Queries) UpsertProfilePinSetForOrg(ctx context.Context, db DBTX, ownerOrgID pgtype.Int8) (int64, error) { | |
| 994 | + row := db.QueryRow(ctx, upsertProfilePinSetForOrg, ownerOrgID) | |
| 995 | + var id int64 | |
| 996 | + err := row.Scan(&id) | |
| 997 | + return id, err | |
| 998 | +} | |
| 999 | + | |
| 1000 | +const upsertProfilePinSetForUser = `-- name: UpsertProfilePinSetForUser :one | |
| 1001 | +INSERT INTO profile_pin_sets (owner_user_id) | |
| 1002 | +VALUES ($1) | |
| 1003 | +ON CONFLICT (owner_user_id) WHERE owner_user_id IS NOT NULL | |
| 1004 | +DO UPDATE SET updated_at = now() | |
| 1005 | +RETURNING id | |
| 1006 | +` | |
| 1007 | + | |
| 1008 | +func (q *Queries) UpsertProfilePinSetForUser(ctx context.Context, db DBTX, ownerUserID pgtype.Int8) (int64, error) { | |
| 1009 | + row := db.QueryRow(ctx, upsertProfilePinSetForUser, ownerUserID) | |
| 1010 | + var id int64 | |
| 1011 | + err := row.Scan(&id) | |
| 1012 | + return id, err | |
| 1013 | +} | |
internal/users/sqlc/models.gomodified@@ -1629,6 +1629,20 @@ type Principal struct { | ||
| 1629 | 1629 | ID int64 |
| 1630 | 1630 | } |
| 1631 | 1631 | |
| 1632 | +type ProfilePin struct { | |
| 1633 | + SetID int64 | |
| 1634 | + RepoID int64 | |
| 1635 | + Position int32 | |
| 1636 | + PinnedAt pgtype.Timestamptz | |
| 1637 | +} | |
| 1638 | + | |
| 1639 | +type ProfilePinSet struct { | |
| 1640 | + ID int64 | |
| 1641 | + OwnerUserID pgtype.Int8 | |
| 1642 | + OwnerOrgID pgtype.Int8 | |
| 1643 | + UpdatedAt pgtype.Timestamptz | |
| 1644 | +} | |
| 1645 | + | |
| 1632 | 1646 | type PullRequest struct { |
| 1633 | 1647 | IssueID int64 |
| 1634 | 1648 | BaseRef string |
internal/webhook/sqlc/models.gomodified@@ -1629,6 +1629,20 @@ type Principal struct { | ||
| 1629 | 1629 | ID int64 |
| 1630 | 1630 | } |
| 1631 | 1631 | |
| 1632 | +type ProfilePin struct { | |
| 1633 | + SetID int64 | |
| 1634 | + RepoID int64 | |
| 1635 | + Position int32 | |
| 1636 | + PinnedAt pgtype.Timestamptz | |
| 1637 | +} | |
| 1638 | + | |
| 1639 | +type ProfilePinSet struct { | |
| 1640 | + ID int64 | |
| 1641 | + OwnerUserID pgtype.Int8 | |
| 1642 | + OwnerOrgID pgtype.Int8 | |
| 1643 | + UpdatedAt pgtype.Timestamptz | |
| 1644 | +} | |
| 1645 | + | |
| 1632 | 1646 | type PullRequest struct { |
| 1633 | 1647 | IssueID int64 |
| 1634 | 1648 | BaseRef string |
internal/worker/sqlc/models.gomodified@@ -1629,6 +1629,20 @@ type Principal struct { | ||
| 1629 | 1629 | ID int64 |
| 1630 | 1630 | } |
| 1631 | 1631 | |
| 1632 | +type ProfilePin struct { | |
| 1633 | + SetID int64 | |
| 1634 | + RepoID int64 | |
| 1635 | + Position int32 | |
| 1636 | + PinnedAt pgtype.Timestamptz | |
| 1637 | +} | |
| 1638 | + | |
| 1639 | +type ProfilePinSet struct { | |
| 1640 | + ID int64 | |
| 1641 | + OwnerUserID pgtype.Int8 | |
| 1642 | + OwnerOrgID pgtype.Int8 | |
| 1643 | + UpdatedAt pgtype.Timestamptz | |
| 1644 | +} | |
| 1645 | + | |
| 1632 | 1646 | type PullRequest struct { |
| 1633 | 1647 | IssueID int64 |
| 1634 | 1648 | BaseRef string |