···489489 query = `select count(id) from repos where did = ?`
490490 args = append(args, did)
491491 case models.VanityStatStarCount:
492492- query = `select count(id) from stars where subject_at like 'at://' || ? || '%'`
492492+ query = `select count(s.id) from stars s join repos r on s.subject = r.repo_did where s.subject_type = 'repo' and r.did = ?`
493493 args = append(args, did)
494494 case models.VanityStatNone:
495495 return 0, nil
+56-57
appview/db/pulls.go
···3030 if existing.Branch != new.Branch {
3131 return false
3232 }
3333- if existing.RepoAt == nil && new.RepoAt == nil {
3333+ if existing.RepoDid == nil && new.RepoDid == nil {
3434 return true
3535 }
3636- if existing.RepoAt == nil || new.RepoAt == nil {
3636+ if existing.RepoDid == nil || new.RepoDid == nil {
3737 return false
3838 }
3939- return *existing.RepoAt == *new.RepoAt
3939+ return *existing.RepoDid == *new.RepoDid
4040}
41414242func compareSubmissions(existing, new []*models.PullSubmission) bool {
···6060func PutPull(tx *sql.Tx, pull *models.Pull) error {
6161 // ensure sequence exists
6262 _, err := tx.Exec(`
6363- insert or ignore into repo_pull_seqs (repo_at, next_pull_id)
6363+ insert or ignore into repo_pull_seqs (repo_did, next_pull_id)
6464 values (?, 1)
6565- `, pull.RepoAt)
6565+ `, pull.RepoDid)
6666 if err != nil {
6767 return err
6868 }
···9494 if existingPull.Title == pull.Title &&
9595 existingPull.Body == pull.Body &&
9696 existingPull.TargetBranch == pull.TargetBranch &&
9797- existingPull.RepoAt == pull.RepoAt &&
9797+ existingPull.RepoDid == pull.RepoDid &&
9898 dependentOnEqual &&
9999 pullSourceEqual &&
100100 submissionsEqual {
···119119120120func createNewPull(tx *sql.Tx, pull *models.Pull) error {
121121 _, err := tx.Exec(`
122122- insert or ignore into repo_pull_seqs (repo_at, next_pull_id)
122122+ insert or ignore into repo_pull_seqs (repo_did, next_pull_id)
123123 values (?, 1)
124124- `, pull.RepoAt)
124124+ `, pull.RepoDid)
125125 if err != nil {
126126 return err
127127 }
···130130 err = tx.QueryRow(`
131131 update repo_pull_seqs
132132 set next_pull_id = next_pull_id + 1
133133- where repo_at = ?
133133+ where repo_did = ?
134134 returning next_pull_id - 1
135135- `, pull.RepoAt).Scan(&nextId)
135135+ `, pull.RepoDid).Scan(&nextId)
136136 if err != nil {
137137 return err
138138 }
···140140 pull.PullId = nextId
141141 pull.State = models.PullOpen
142142143143- var sourceBranch, sourceRepoAt *string
143143+ var sourceBranch, sourceRepoDid *string
144144 if pull.PullSource != nil {
145145 sourceBranch = &pull.PullSource.Branch
146146- if pull.PullSource.RepoAt != nil {
147147- x := pull.PullSource.RepoAt.String()
148148- sourceRepoAt = &x
146146+ if pull.PullSource.RepoDid != nil {
147147+ x := string(*pull.PullSource.RepoDid)
148148+ sourceRepoDid = &x
149149 }
150150 }
151151152152 result, err := tx.Exec(
153153 `
154154 insert into pulls (
155155- repo_at,
155155+ repo_did,
156156 owner_did,
157157 pull_id,
158158 title,
···162162 state,
163163 dependent_on,
164164 source_branch,
165165- source_repo_at
165165+ source_repo_did
166166 )
167167 values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
168168- pull.RepoAt,
168168+ pull.RepoDid,
169169 pull.OwnerDid,
170170 pull.PullId,
171171 pull.Title,
···175175 pull.State,
176176 pull.DependentOn,
177177 sourceBranch,
178178- sourceRepoAt,
178178+ sourceRepoDid,
179179 )
180180 if err != nil {
181181 return err
···224224}
225225226226func updatePull(tx *sql.Tx, pull *models.Pull, existingPull *models.Pull) error {
227227- var sourceBranch, sourceRepoAt *string
227227+ var sourceBranch, sourceRepoDid *string
228228 if pull.PullSource != nil {
229229 sourceBranch = &pull.PullSource.Branch
230230- if pull.PullSource.RepoAt != nil {
231231- x := pull.PullSource.RepoAt.String()
232232- sourceRepoAt = &x
230230+ if pull.PullSource.RepoDid != nil {
231231+ x := string(*pull.PullSource.RepoDid)
232232+ sourceRepoDid = &x
233233 }
234234 }
235235···240240 target_branch = ?,
241241 dependent_on = ?,
242242 source_branch = ?,
243243- source_repo_at = ?
243243+ source_repo_did = ?
244244 where owner_did = ? and rkey = ?
245245- `, pull.Title, pull.Body, pull.TargetBranch, pull.DependentOn, sourceBranch, sourceRepoAt, pull.OwnerDid, pull.Rkey)
245245+ `, pull.Title, pull.Body, pull.TargetBranch, pull.DependentOn, sourceBranch, sourceRepoDid, pull.OwnerDid, pull.Rkey)
246246 if err != nil {
247247 return err
248248 }
···283283 return nil
284284}
285285286286-func NextPullId(e Execer, repoAt syntax.ATURI) (int, error) {
286286+func NextPullId(e Execer, repoDid string) (int, error) {
287287 var pullId int
288288- err := e.QueryRow(`select next_pull_id from repo_pull_seqs where repo_at = ?`, repoAt).Scan(&pullId)
288288+ err := e.QueryRow(`select next_pull_id from repo_pull_seqs where repo_did = ?`, repoDid).Scan(&pullId)
289289 return pullId - 1, err
290290}
291291···316316 select
317317 id,
318318 owner_did,
319319- repo_at,
319319+ repo_did,
320320 pull_id,
321321 created,
322322 title,
···325325 body,
326326 rkey,
327327 source_branch,
328328- source_repo_at,
328328+ source_repo_did,
329329 dependent_on
330330 from
331331 pulls
···344344 for rows.Next() {
345345 var pull models.Pull
346346 var createdAt string
347347- var sourceBranch, sourceRepoAt, dependentOn sql.NullString
347347+ var sourceBranch, sourceRepoDid, dependentOn sql.NullString
348348 err := rows.Scan(
349349 &pull.ID,
350350 &pull.OwnerDid,
351351- &pull.RepoAt,
351351+ &pull.RepoDid,
352352 &pull.PullId,
353353 &createdAt,
354354 &pull.Title,
···357357 &pull.Body,
358358 &pull.Rkey,
359359 &sourceBranch,
360360- &sourceRepoAt,
360360+ &sourceRepoDid,
361361 &dependentOn,
362362 )
363363 if err != nil {
···374374 pull.PullSource = &models.PullSource{
375375 Branch: sourceBranch.String,
376376 }
377377- if sourceRepoAt.Valid {
378378- sourceRepoAtParsed, err := syntax.ParseATURI(sourceRepoAt.String)
377377+ if sourceRepoDid.Valid {
378378+ sourceRepoDidParsed, err := syntax.ParseDID(sourceRepoDid.String)
379379 if err != nil {
380380 return nil, err
381381 }
382382- pull.PullSource.RepoAt = &sourceRepoAtParsed
382382+ pull.PullSource.RepoDid = &sourceRepoDidParsed
383383 }
384384 }
385385···417417 }
418418 }
419419420420- // build up reverse mappings: p.Repo and p.PullSource
421421- var repoAts []syntax.ATURI
420420+ // build up reverse mappings: p.Repo and p.PullSource.Repo
421421+ var repoDids []syntax.DID
422422 for _, p := range pulls {
423423- repoAts = append(repoAts, p.RepoAt)
424424- if p.PullSource != nil && p.PullSource.RepoAt != nil {
425425- repoAts = append(repoAts, *p.PullSource.RepoAt)
423423+ repoDids = append(repoDids, p.RepoDid)
424424+ if p.PullSource != nil && p.PullSource.RepoDid != nil {
425425+ repoDids = append(repoDids, *p.PullSource.RepoDid)
426426 }
427427 }
428428429429- repos, err := GetRepos(e, orm.FilterIn("at_uri", repoAts))
429429+ repos, err := GetRepos(e, orm.FilterIn("repo_did", repoDids))
430430 if err != nil && !errors.Is(err, sql.ErrNoRows) {
431431- return nil, fmt.Errorf("failed to get source repos: %w", err)
431431+ return nil, fmt.Errorf("failed to get repos: %w", err)
432432 }
433433434434- repoMap := make(map[syntax.ATURI]*models.Repo)
434434+ repoMap := make(map[syntax.DID]*models.Repo)
435435 for _, r := range repos {
436436- repoMap[r.RepoAt()] = &r
436436+ repoMap[syntax.DID(r.RepoDid)] = &r
437437 }
438438439439 for _, p := range pulls {
440440- if repo, ok := repoMap[p.RepoAt]; ok {
440440+ if repo, ok := repoMap[p.RepoDid]; ok {
441441 p.Repo = repo
442442 }
443443-444444- if p.PullSource != nil && p.PullSource.RepoAt != nil {
445445- if sourceRepo, ok := repoMap[*p.PullSource.RepoAt]; ok {
443443+ if p.PullSource != nil && p.PullSource.RepoDid != nil {
444444+ if sourceRepo, ok := repoMap[*p.PullSource.RepoDid]; ok {
446445 p.PullSource.Repo = sourceRepo
447446 }
448447 }
···625624 id,
626625 pull_id,
627626 submission_id,
628628- repo_at,
627627+ repo_did,
629628 owner_did,
630629 comment_at,
631630 body,
···651650 &comment.ID,
652651 &comment.PullId,
653652 &comment.SubmissionId,
654654- &comment.RepoAt,
653653+ &comment.RepoDid,
655654 &comment.OwnerDid,
656655 &comment.CommentAt,
657656 &comment.Body,
···705704 rows, err := e.Query(`
706705 select
707706 p.owner_did,
708708- p.repo_at,
707707+ p.repo_did,
709708 p.pull_id,
710709 p.created,
711710 p.title,
···718717 from
719718 pulls p
720719 join
721721- repos r on p.repo_at = r.at_uri
720720+ repos r on p.repo_did = r.repo_did
722721 where
723722 p.owner_did = ? and p.created >= date ('now', ?)
724723 order by
···734733 var pullCreatedAt, repoCreatedAt string
735734 err := rows.Scan(
736735 &pull.OwnerDid,
737737- &pull.RepoAt,
736736+ &pull.RepoDid,
738737 &pull.PullId,
739738 &pullCreatedAt,
740739 &pull.Title,
···774773}
775774776775func NewPullComment(tx *sql.Tx, comment *models.PullComment) (int64, error) {
777777- query := `insert into pull_comments (owner_did, repo_at, submission_id, comment_at, pull_id, body) values (?, ?, ?, ?, ?, ?)`
776776+ query := `insert into pull_comments (owner_did, repo_did, submission_id, comment_at, pull_id, body) values (?, ?, ?, ?, ?, ?)`
778777 res, err := tx.Exec(
779778 query,
780779 comment.OwnerDid,
781781- comment.RepoAt,
780780+ comment.RepoDid,
782781 comment.SubmissionId,
783782 comment.CommentAt,
784783 comment.PullId,
···888887 return err
889888}
890889891891-func GetPullCount(e Execer, repoAt syntax.ATURI) (models.PullCount, error) {
890890+func GetPullCount(e Execer, repoDid string) (models.PullCount, error) {
892891 row := e.QueryRow(`
893892 select
894893 count(case when state = ? then 1 end) as open_count,
···896895 count(case when state = ? then 1 end) as closed_count,
897896 count(case when state = ? then 1 end) as deleted_count
898897 from pulls
899899- where repo_at = ?`,
898898+ where repo_did = ?`,
900899 models.PullOpen,
901900 models.PullMerged,
902901 models.PullClosed,
903902 models.PullAbandoned,
904904- repoAt,
903903+ repoDid,
905904 )
906905907906 var count models.PullCount
+8-8
appview/db/reference.go
···6060 on r.did = inp.owner_did
6161 and r.name = inp.name
6262 join issues i
6363- on i.repo_at = r.at_uri
6363+ on i.repo_did = r.repo_did
6464 and i.issue_id = inp.issue_id
6565 left join issue_comments c
6666 on inp.comment_id is not null
···131131 on r.did = inp.owner_did
132132 and r.name = inp.name
133133 join pulls p
134134- on p.repo_at = r.at_uri
134134+ on p.repo_did = r.repo_did
135135 and p.pull_id = inp.pull_id
136136 left join pull_comments c
137137 on inp.comment_id is not null
138138- and c.repo_at = r.at_uri and c.pull_id = p.pull_id
138138+ and c.repo_did = p.repo_did and c.pull_id = p.pull_id
139139 and c.id = inp.comment_id
140140 `,
141141 strings.Join(vals, ","),
···319319 `select r.did, r.name, i.issue_id, i.title, i.open
320320 from issues i
321321 join repos r
322322- on r.at_uri = i.repo_at
322322+ on r.repo_did = i.repo_did
323323 where (i.did, i.rkey) in (%s)`,
324324 strings.Join(vals, ","),
325325 ),
···357357 join issues i
358358 on i.at_uri = c.issue_at
359359 join repos r
360360- on r.at_uri = i.repo_at
360360+ on r.repo_did = i.repo_did
361361 where %s and %s`,
362362 filter.Condition(),
363363 exclude.Condition(),
···401401 `select r.did, r.name, p.pull_id, p.title, p.state
402402 from pulls p
403403 join repos r
404404- on r.at_uri = p.repo_at
404404+ on r.repo_did = p.repo_did
405405 where (p.owner_did, p.rkey) in (%s)`,
406406 strings.Join(vals, ","),
407407 ),
···437437 `select r.did, r.name, p.pull_id, c.id, p.title, p.state
438438 from repos r
439439 join pulls p
440440- on r.at_uri = p.repo_at
440440+ on r.repo_did = p.repo_did
441441 join pull_comments c
442442- on r.at_uri = c.repo_at and p.pull_id = c.pull_id
442442+ on p.repo_did = c.repo_did and p.pull_id = c.pull_id
443443 where %s and %s`,
444444 filter.Condition(),
445445 exclude.Condition(),
+67-68
appview/db/repos.go
···6464 }
6565 defer rows.Close()
66666767- repoMap := make(map[syntax.ATURI]*models.Repo)
6767+ repoMap := make(map[string]*models.Repo)
6868 for rows.Next() {
6969 var repo models.Repo
7070 var createdAt string
···114114 }
115115116116 repo.RepoStats = &models.RepoStats{}
117117- repoMap[repo.RepoAt()] = &repo
117117+ repoMap[repo.RepoDid] = &repo
118118 }
119119120120 if err = rows.Err(); err != nil {
···131131 args = make([]any, len(repoMap))
132132 i := 0
133133 for _, r := range repoMap {
134134- args[i] = r.RepoAt()
134134+ args[i] = r.RepoDid
135135 i++
136136 }
137137138138 // get labels for all repos
139139 labelsQuery := fmt.Sprintf(
140140- `select repo_at, label_at from repo_labels where repo_at in (%s)`,
140140+ `select repo_did, label_at from repo_labels where repo_did in (%s)`,
141141 inClause,
142142 )
143143···148148 defer rows.Close()
149149150150 for rows.Next() {
151151- var repoat, labelat string
152152- if err := rows.Scan(&repoat, &labelat); err != nil {
151151+ var repoDid, labelat string
152152+ if err := rows.Scan(&repoDid, &labelat); err != nil {
153153 continue
154154 }
155155- if r, ok := repoMap[syntax.ATURI(repoat)]; ok {
155155+ if r, ok := repoMap[repoDid]; ok {
156156 r.Labels = append(r.Labels, labelat)
157157 }
158158 }
159159160160 // get primary language for all repos
161161 languageQuery := fmt.Sprintf(`
162162- select repo_at, language
162162+ select repo_did, language
163163 from (
164164 select
165165- repo_at, language,
165165+ repo_did, language,
166166 row_number() over (
167167- partition by repo_at
167167+ partition by repo_did
168168 order by bytes desc
169169 ) as rn
170170 from repo_languages
171171- where repo_at in (%s)
171171+ where repo_did in (%s)
172172 and is_default_ref = 1
173173 and language <> ''
174174 )
···182182 defer rows.Close()
183183184184 for rows.Next() {
185185- var repoat, lang string
186186- if err := rows.Scan(&repoat, &lang); err != nil {
185185+ var repoDid, lang string
186186+ if err := rows.Scan(&repoDid, &lang); err != nil {
187187 log.Println("err", "err", err)
188188 continue
189189 }
190190- if r, ok := repoMap[syntax.ATURI(repoat)]; ok {
190190+ if r, ok := repoMap[repoDid]; ok {
191191 r.RepoStats.Language = lang
192192 }
193193 }
···197197198198 // get star counts
199199 starCountQuery := fmt.Sprintf(
200200- `select subject_at, count(1) from stars where subject_at in (%s) group by subject_at`,
200200+ `select subject, count(1) from stars where subject_type = 'repo' and subject in (%s) group by subject`,
201201 inClause,
202202 )
203203···208208 defer rows.Close()
209209210210 for rows.Next() {
211211- var repoat string
211211+ var repoDid string
212212 var count int
213213- if err := rows.Scan(&repoat, &count); err != nil {
213213+ if err := rows.Scan(&repoDid, &count); err != nil {
214214 log.Println("err", "err", err)
215215 continue
216216 }
217217- if r, ok := repoMap[syntax.ATURI(repoat)]; ok {
217217+ if r, ok := repoMap[repoDid]; ok {
218218 r.RepoStats.StarCount = count
219219 }
220220 }
···225225 // get issue counts
226226 issueCountQuery := fmt.Sprintf(`
227227 select
228228- repo_at,
228228+ repo_did,
229229 count(case when open = 1 then 1 end) as open_count,
230230 count(case when open = 0 then 1 end) as closed_count
231231 from issues
232232- where repo_at in (%s)
233233- group by repo_at
232232+ where repo_did in (%s)
233233+ group by repo_did
234234 `, inClause)
235235236236 rows, err = e.Query(issueCountQuery, args...)
···240240 defer rows.Close()
241241242242 for rows.Next() {
243243- var repoat string
243243+ var repoDid string
244244 var open, closed int
245245- if err := rows.Scan(&repoat, &open, &closed); err != nil {
245245+ if err := rows.Scan(&repoDid, &open, &closed); err != nil {
246246 log.Println("err", "err", err)
247247 continue
248248 }
249249- if r, ok := repoMap[syntax.ATURI(repoat)]; ok {
249249+ if r, ok := repoMap[repoDid]; ok {
250250 r.RepoStats.IssueCount.Open = open
251251 r.RepoStats.IssueCount.Closed = closed
252252 }
···258258 // get pull counts
259259 pullCountQuery := fmt.Sprintf(`
260260 select
261261- repo_at,
261261+ repo_did,
262262 count(case when state = ? then 1 end) as open_count,
263263 count(case when state = ? then 1 end) as merged_count,
264264 count(case when state = ? then 1 end) as closed_count,
265265 count(case when state = ? then 1 end) as deleted_count
266266 from pulls
267267- where repo_at in (%s)
268268- group by repo_at
267267+ where repo_did in (%s)
268268+ group by repo_did
269269 `, inClause)
270270271271 pullArgs := append([]any{
···282282 defer rows.Close()
283283284284 for rows.Next() {
285285- var repoat string
285285+ var repoDid string
286286 var open, merged, closed, deleted int
287287- if err := rows.Scan(&repoat, &open, &merged, &closed, &deleted); err != nil {
287287+ if err := rows.Scan(&repoDid, &open, &merged, &closed, &deleted); err != nil {
288288 log.Println("err", "err", err)
289289 continue
290290 }
291291- if r, ok := repoMap[syntax.ATURI(repoat)]; ok {
291291+ if r, ok := repoMap[repoDid]; ok {
292292 r.RepoStats.PullCount.Open = open
293293 r.RepoStats.PullCount.Merged = merged
294294 r.RepoStats.PullCount.Closed = closed
···404404 }
405405 _, err := tx.Exec(
406406 `update repos
407407- set knot = ?, description = ?, website = ?, topics = ?, repo_did = coalesce(?, repo_did)
407407+ set name = ?, knot = ?, description = ?, website = ?, topics = ?, repo_did = coalesce(?, repo_did)
408408 where did = ? and rkey = ?
409409 `,
410410- repo.Knot, repo.Description, repo.Website, repo.TopicStr(), repoDid, repo.Did, repo.Rkey,
410410+ repo.Name, repo.Knot, repo.Description, repo.Website, repo.TopicStr(), repoDid, repo.Did, repo.Rkey,
411411 )
412412 return err
413413}
···435435436436 for _, dl := range repo.Labels {
437437 if err := SubscribeLabel(tx, &models.RepoLabel{
438438- RepoAt: repo.RepoAt(),
438438+ RepoDid: syntax.DID(repo.RepoDid),
439439 LabelAt: syntax.ATURI(dl),
440440 }); err != nil {
441441 return fmt.Errorf("failed to subscribe to label: %w", err)
···445445 return nil
446446}
447447448448-func RemoveRepo(e Execer, did, name string) error {
449449- _, err := e.Exec(`delete from repos where did = ? and name = ?`, did, name)
448448+func RemoveRepo(e Execer, did, rkey string) error {
449449+ _, err := e.Exec(`delete from repos where did = ? and rkey = ?`, did, rkey)
450450 return err
451451}
452452453453-func GetRepoSource(e Execer, repoAt syntax.ATURI) (string, error) {
453453+func GetRepoSource(e Execer, repoDid string) (string, error) {
454454 var nullableSource sql.NullString
455455- err := e.QueryRow(`select source from repos where at_uri = ?`, repoAt).Scan(&nullableSource)
455455+ err := e.QueryRow(`select source from repos where repo_did = ?`, repoDid).Scan(&nullableSource)
456456 if err != nil {
457457 return "", err
458458 }
459459 return nullableSource.String, nil
460460}
461461462462-func GetRepoSourceRepo(e Execer, repoAt syntax.ATURI) (*models.Repo, error) {
463463- source, err := GetRepoSource(e, repoAt)
462462+func GetRepoSourceRepo(e Execer, repoDid string) (*models.Repo, error) {
463463+ source, err := GetRepoSource(e, repoDid)
464464 if source == "" || errors.Is(err, sql.ErrNoRows) {
465465 return nil, nil
466466 }
···479479 rows, err := e.Query(
480480 `select distinct r.id, r.did, r.name, r.knot, r.rkey, r.description, r.website, r.created, r.source, r.repo_did
481481 from repos r
482482- left join collaborators c on r.at_uri = c.repo_at
482482+ left join collaborators c on r.repo_did = c.repo_did
483483 where (r.did = ? or c.subject_did = ?)
484484 and r.source is not null
485485 and r.source != ''
···535535 return repos, nil
536536}
537537538538-func GetForkByDid(e Execer, did string, name string) (*models.Repo, error) {
538538+func GetForkByDid(e Execer, did string, rkey string) (*models.Repo, error) {
539539 var repo models.Repo
540540 var createdAt string
541541 var nullableDescription sql.NullString
···547547 row := e.QueryRow(
548548 `select id, did, name, knot, rkey, description, website, topics, created, source, repo_did
549549 from repos
550550- where did = ? and name = ? and source is not null and source != ''`,
551551- did, name,
550550+ where did = ? and rkey = ? and source is not null and source != ''`,
551551+ did, rkey,
552552 )
553553554554 err := row.Scan(&repo.Id, &repo.Did, &repo.Name, &repo.Knot, &repo.Rkey, &nullableDescription, &nullableWebsite, &nullableTopicStr, &createdAt, &nullableSource, &nullableRepoDid)
···595595 table string
596596 nsid string
597597 fkCol string
598598+ fkVal string
598599 }
599600 sources := []record{
600600- {"did", "repos", "sh.tangled.repo", "at_uri"},
601601- {"did", "issues", "sh.tangled.repo.issue", "repo_at"},
602602- {"owner_did", "pulls", "sh.tangled.repo.pull", "repo_at"},
603603- {"did", "collaborators", "sh.tangled.repo.collaborator", "repo_at"},
604604- {"did", "artifacts", "sh.tangled.repo.artifact", "repo_at"},
605605- {"did", "stars", "sh.tangled.feed.star", "subject_at"},
601601+ {"did", "repos", "sh.tangled.repo", "at_uri", repoAtUri},
602602+ {"did", "issues", "sh.tangled.repo.issue", "repo_did", repoDid},
603603+ {"owner_did", "pulls", "sh.tangled.repo.pull", "repo_did", repoDid},
604604+ {"did", "collaborators", "sh.tangled.repo.collaborator", "repo_did", repoDid},
605605+ {"did", "artifacts", "sh.tangled.repo.artifact", "repo_did", repoDid},
606606+ {"did", "stars", "sh.tangled.feed.star", "subject", repoDid},
606607 }
607608608609 for _, src := range sources {
609610 rows, err := tx.Query(
610611 fmt.Sprintf(`SELECT %s, rkey FROM %s WHERE %s = ?`, src.userDidCol, src.table, src.fkCol),
611611- repoAtUri,
612612+ src.fkVal,
612613 )
613614 if err != nil {
614615 return fmt.Errorf("query %s for pds rewrites: %w", src.table, err)
···629630 }
630631631632 for _, p := range pairs {
632632- if err := EnqueuePdsRewrite(tx, p.did, repoDid, src.nsid, p.rkey, repoAtUri); err != nil {
633633+ if err := EnqueuePdsRewrite(tx, p.did, repoDid, src.nsid, p.rkey); err != nil {
633634 return fmt.Errorf("enqueue pds rewrite for %s/%s: %w", src.table, p.rkey, err)
634635 }
635636 }
···657658 }
658659659660 for _, d := range profileDids {
660660- if err := EnqueuePdsRewrite(tx, d, repoDid, "sh.tangled.actor.profile", "self", repoAtUri); err != nil {
661661+ if err := EnqueuePdsRewrite(tx, d, repoDid, "sh.tangled.actor.profile", "self"); err != nil {
661662 return fmt.Errorf("enqueue pds rewrite for profile/%s: %w", d, err)
662663 }
663664 }
···670671 RepoDid string
671672 RecordNsid string
672673 RecordRkey string
673673- OldRepoAt string
674674}
675675676676func GetPendingPdsRewrites(e Execer, userDid string) ([]PdsRewrite, error) {
677677 rows, err := e.Query(
678678- `SELECT id, repo_did, record_nsid, record_rkey, old_repo_at
678678+ `SELECT id, repo_did, record_nsid, record_rkey
679679 FROM pds_rewrite_status
680680 WHERE user_did = ? AND status = 'pending'`,
681681 userDid,
···688688 var rewrites []PdsRewrite
689689 for rows.Next() {
690690 var r PdsRewrite
691691- if err := rows.Scan(&r.Id, &r.RepoDid, &r.RecordNsid, &r.RecordRkey, &r.OldRepoAt); err != nil {
691691+ if err := rows.Scan(&r.Id, &r.RepoDid, &r.RecordNsid, &r.RecordRkey); err != nil {
692692 return nil, err
693693 }
694694 rewrites = append(rewrites, r)
···704704 return err
705705}
706706707707-func EnqueuePdsRewrite(e Execer, userDid, repoDid, recordNsid, recordRkey, oldRepoAt string) error {
707707+func EnqueuePdsRewrite(e Execer, userDid, repoDid, recordNsid, recordRkey string) error {
708708 _, err := e.Exec(
709709 `INSERT INTO pds_rewrite_status
710710- (user_did, repo_did, record_nsid, record_rkey, old_repo_at, status)
711711- VALUES (?, ?, ?, ?, ?, 'pending')
710710+ (user_did, repo_did, record_nsid, record_rkey, status)
711711+ VALUES (?, ?, ?, ?, 'pending')
712712 ON CONFLICT(user_did, record_nsid, record_rkey) DO UPDATE SET
713713 status = 'pending',
714714 repo_did = excluded.repo_did,
715715- old_repo_at = excluded.old_repo_at,
716715 updated_at = strftime('%Y-%m-%dT%H:%M:%SZ', 'now')`,
717717- userDid, repoDid, recordNsid, recordRkey, oldRepoAt,
716716+ userDid, repoDid, recordNsid, recordRkey,
718717 )
719718 return err
720719}
···739738 return nil
740739}
741740742742-func UpdateDescription(e Execer, repoAt, newDescription string) error {
741741+func UpdateDescription(e Execer, repoDid, newDescription string) error {
743742 _, err := e.Exec(
744744- `update repos set description = ? where at_uri = ?`, newDescription, repoAt)
743743+ `update repos set description = ? where repo_did = ?`, newDescription, repoDid)
745744 return err
746745}
747746748748-func UpdateSpindle(e Execer, repoAt string, spindle *string) error {
747747+func UpdateSpindle(e Execer, repoDid string, spindle *string) error {
749748 _, err := e.Exec(
750750- `update repos set spindle = ? where at_uri = ?`, spindle, repoAt)
749749+ `update repos set spindle = ? where repo_did = ?`, spindle, repoDid)
751750 return err
752751}
753752754753func SubscribeLabel(e Execer, rl *models.RepoLabel) error {
755755- query := `insert or ignore into repo_labels (repo_at, label_at) values (?, ?)`
754754+ query := `insert or ignore into repo_labels (repo_did, label_at) values (?, ?)`
756755757757- _, err := e.Exec(query, rl.RepoAt.String(), rl.LabelAt.String())
756756+ _, err := e.Exec(query, string(rl.RepoDid), rl.LabelAt.String())
758757 return err
759758}
760759···789788 whereClause = " where " + strings.Join(conditions, " and ")
790789 }
791790792792- query := fmt.Sprintf(`select id, repo_at, label_at from repo_labels %s`, whereClause)
791791+ query := fmt.Sprintf(`select id, repo_did, label_at from repo_labels %s`, whereClause)
793792794793 rows, err := e.Query(query, args...)
795794 if err != nil {
···801800 for rows.Next() {
802801 var label models.RepoLabel
803802804804- err := rows.Scan(&label.Id, &label.RepoAt, &label.LabelAt)
803803+ err := rows.Scan(&label.Id, &label.RepoDid, &label.LabelAt)
805804 if err != nil {
806805 return nil, err
807806 }