Monorepo for Tangled tangled.org

appview: repo: implement generating feed #476

merged opened by ptr.pet targeting master from [deleted fork]: repo-feed
Labels

None yet.

assignee

None yet.

Participants 2
AT URI
at://did:plc:dfl62fgb7wtjj3fcbb72naae/sh.tangled.repo.pull/3lw7rerhbqm22
+43 -28
Interdiff #1 โ†’ #2
+43 -28
appview/repo/repo.go
··· 270 270 } 271 271 } 272 272 273 + func (rp *Repo) RepoCommit(w http.ResponseWriter, r *http.Request) { 274 + f, err := rp.repoResolver.Resolve(r) 275 + if err != nil { 276 + 277 + 278 + 279 + 280 + 281 + 282 + 283 + 284 + 285 + 286 + 287 + 288 + 289 + } 290 + } 291 + 273 292 func (rp *Repo) getRepoFeed(ctx context.Context, f *reporesolver.ResolvedRepo) (*feeds.Feed, error) { 274 293 const feedLimitPerType = 100 275 294 276 - pulls, err := db.GetAnyPulls(rp.db, f.RepoAt, feedLimitPerType) 295 + pulls, err := db.GetPullsWithLimit(rp.db, feedLimitPerType, db.FilterEq("repo_at", f.RepoAt())) 277 296 if err != nil { 278 297 return nil, err 279 298 } 280 299 281 - issues, err := db.GetAnyIssues(rp.db, f.RepoAt, feedLimitPerType) 300 + issues, err := db.GetIssuesWithLimit(rp.db, feedLimitPerType, db.FilterEq("repo_at", f.RepoAt())) 282 301 if err != nil { 283 302 return nil, err 284 303 } ··· 295 314 if err != nil { 296 315 return nil, err 297 316 } 317 + var state string 318 + if pull.State == db.PullOpen { 319 + state = "opened" 320 + } else { 321 + state = pull.State.String() 322 + } 298 323 item := &feeds.Item{ 299 - Title: fmt.Sprintf("@%s created pull request on %s", owner.Handle, f.OwnerSlashRepo()), 300 - Link: &feeds.Link{Href: fmt.Sprintf("%s/%s/pulls/%d", rp.config.Core.AppviewHost, f.OwnerSlashRepo(), pull.PullId)}, 301 - Created: pull.Created, 324 + Title: fmt.Sprintf("[PR] %s", pull.Title), 325 + Description: fmt.Sprintf("@%s %s pull request on %s", owner.Handle, state, f.OwnerSlashRepo()), 326 + Link: &feeds.Link{Href: fmt.Sprintf("%s/%s/pulls/%d", rp.config.Core.AppviewHost, f.OwnerSlashRepo(), pull.PullId)}, 327 + Created: pull.Created, 302 328 Author: &feeds.Author{ 303 329 Name: fmt.Sprintf("@%s", owner.Handle), 304 330 }, ··· 311 337 if err != nil { 312 338 return nil, err 313 339 } 340 + var state string 341 + if issue.Open { 342 + state = "opened" 343 + } else { 344 + state = "closed" 345 + } 314 346 item := &feeds.Item{ 315 - Title: fmt.Sprintf("@%s opened issue on %s", owner.Handle, f.OwnerSlashRepo()), 316 - Link: &feeds.Link{Href: fmt.Sprintf("%s/%s/issues/%d", rp.config.Core.AppviewHost, f.OwnerSlashRepo(), issue.IssueId)}, 317 - Created: issue.Created, 347 + Title: fmt.Sprintf("[Issue] %s", issue.Title), 348 + Description: fmt.Sprintf("@%s %s issue on %s", owner.Handle, state, f.OwnerSlashRepo()), 349 + Link: &feeds.Link{Href: fmt.Sprintf("%s/%s/issues/%d", rp.config.Core.AppviewHost, f.OwnerSlashRepo(), issue.IssueId)}, 350 + Created: issue.Created, 318 351 Author: &feeds.Author{ 319 352 Name: fmt.Sprintf("@%s", owner.Handle), 320 353 }, ··· 335 368 func (rp *Repo) RepoAtomFeed(w http.ResponseWriter, r *http.Request) { 336 369 f, err := rp.repoResolver.Resolve(r) 337 370 if err != nil { 338 - log.Println("failed to fully resolve repo", err) 371 + log.Println("failed to fully resolve repo:", err) 339 372 return 340 373 } 341 374 342 375 feed, err := rp.getRepoFeed(r.Context(), f) 343 376 if err != nil { 377 + log.Println("failed to get repo feed:", err) 344 378 rp.pages.Error500(w) 345 379 return 346 380 } ··· 356 390 } 357 391 358 392 func (rp *Repo) RepoCommit(w http.ResponseWriter, r *http.Request) { 359 - f, err := rp.repoResolver.Resolve(r) 360 - if err != nil { 361 - 362 - 363 - 364 - 365 - 366 - 367 - 368 - 369 - 370 - 371 - 372 - 373 - 374 - } 375 - } 376 - 377 - func (rp *Repo) RepoCommit(w http.ResponseWriter, r *http.Request) { 378 393 f, err := rp.repoResolver.Resolve(r) 379 394 if err != nil {
appview/repo/router.go

This file has not been changed.

History

5 rounds 4 comments
sign up or login to add to the discussion
1 commit
expand
bd1694e2
appview: repo: implement generating feed
expand 1 comment

including submissions in the feed now aswell

pull request successfully merged
1 commit
expand
7e9f0eea
appview: repo: implement generating feed
expand 0 comments
1 commit
expand
2851773b
appview: repo: implement generating feed
expand 0 comments
1 commit
expand
381c1840
appview: repo: implement generating feed
expand 2 comments

for the feed title, can we change it to be of the format [Issue] <Issue Title> and [PR] <Pull title>?

made the title that, moved the existing one as description

ptr.pet submitted #0
1 commit
expand
aea5b04f
appview: repo: implement generating feed
expand 1 comment

this is pretty simple for now (only puts pull and issue creation in), like the profile timeline since i assume this could use the same code as notifications code later for keeping track of pulls / issues being closed etc etc