Signed-off-by: dusk y.bera003.06@protonmail.com
+43
-28
appview/repo/repo.go
+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
appview/repo/router.go
This file has not been changed.
History
5 rounds
4 comments
expand 1 comment
pull request successfully merged
expand 0 comments
expand 0 comments
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
including submissions in the feed now aswell