Mirror of @tangled.org/core. Running on a Raspberry Pi Zero 2 (Please be gentle).
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

appview: db/issues: add `ID` field to `Issue`

This will help indexing Issues faster when we introduce external search
indexer

Signed-off-by: Seongmin Lee <boltlessengineer@proton.me>

authored by

Seongmin Lee and committed by
Tangled
f743574a 87d9107d

+17 -6
+17 -6
appview/db/issues.go
··· 9 9 ) 10 10 11 11 type Issue struct { 12 + ID int64 12 13 RepoAt syntax.ATURI 13 14 OwnerDid string 14 15 IssueId int ··· 66 65 67 66 issue.IssueId = nextId 68 67 69 - _, err = tx.Exec(` 68 + res, err := tx.Exec(` 70 69 insert into issues (repo_at, owner_did, issue_id, title, body) 71 70 values (?, ?, ?, ?, ?) 72 71 `, issue.RepoAt, issue.OwnerDid, issue.IssueId, issue.Title, issue.Body) 73 72 if err != nil { 74 73 return err 75 74 } 75 + 76 + lastID, err := res.LastInsertId() 77 + if err != nil { 78 + return err 79 + } 80 + issue.ID = lastID 76 81 77 82 if err := tx.Commit(); err != nil { 78 83 return err ··· 121 114 ` 122 115 with numbered_issue as ( 123 116 select 117 + i.id, 124 118 i.owner_did, 125 119 i.issue_id, 126 120 i.created, ··· 140 132 i.id, i.owner_did, i.issue_id, i.created, i.title, i.body, i.open 141 133 ) 142 134 select 135 + id, 143 136 owner_did, 144 137 issue_id, 145 138 created, ··· 162 153 var issue Issue 163 154 var createdAt string 164 155 var metadata IssueMetadata 165 - err := rows.Scan(&issue.OwnerDid, &issue.IssueId, &createdAt, &issue.Title, &issue.Body, &issue.Open, &metadata.CommentCount) 156 + err := rows.Scan(&issue.ID, &issue.OwnerDid, &issue.IssueId, &createdAt, &issue.Title, &issue.Body, &issue.Open, &metadata.CommentCount) 166 157 if err != nil { 167 158 return nil, err 168 159 } ··· 191 182 192 183 rows, err := e.Query( 193 184 `select 185 + i.id, 194 186 i.owner_did, 195 187 i.repo_at, 196 188 i.issue_id, ··· 223 213 var issueCreatedAt, repoCreatedAt string 224 214 var repo Repo 225 215 err := rows.Scan( 216 + &issue.ID, 226 217 &issue.OwnerDid, 227 218 &issue.RepoAt, 228 219 &issue.IssueId, ··· 268 257 } 269 258 270 259 func GetIssue(e Execer, repoAt syntax.ATURI, issueId int) (*Issue, error) { 271 - query := `select owner_did, created, title, body, open from issues where repo_at = ? and issue_id = ?` 260 + query := `select id, owner_did, created, title, body, open from issues where repo_at = ? and issue_id = ?` 272 261 row := e.QueryRow(query, repoAt, issueId) 273 262 274 263 var issue Issue 275 264 var createdAt string 276 - err := row.Scan(&issue.OwnerDid, &createdAt, &issue.Title, &issue.Body, &issue.Open) 265 + err := row.Scan(&issue.ID, &issue.OwnerDid, &createdAt, &issue.Title, &issue.Body, &issue.Open) 277 266 if err != nil { 278 267 return nil, err 279 268 } ··· 288 277 } 289 278 290 279 func GetIssueWithComments(e Execer, repoAt syntax.ATURI, issueId int) (*Issue, []Comment, error) { 291 - query := `select owner_did, issue_id, created, title, body, open, issue_at from issues where repo_at = ? and issue_id = ?` 280 + query := `select id, owner_did, issue_id, created, title, body, open, issue_at from issues where repo_at = ? and issue_id = ?` 292 281 row := e.QueryRow(query, repoAt, issueId) 293 282 294 283 var issue Issue 295 284 var createdAt string 296 - err := row.Scan(&issue.OwnerDid, &issue.IssueId, &createdAt, &issue.Title, &issue.Body, &issue.Open, &issue.IssueAt) 285 + err := row.Scan(&issue.ID, &issue.OwnerDid, &issue.IssueId, &createdAt, &issue.Title, &issue.Body, &issue.Open, &issue.IssueAt) 297 286 if err != nil { 298 287 return nil, nil, err 299 288 }