@@ -322,6 +322,10 @@ var issueReposQueryPattern = regexp.MustCompile(`^\[\d+(,\d+)*,?\]$`)
322
322
323
323
// Issues render the user issues page
324
324
func Issues (ctx * context.Context ) {
325
+
326
+ // Distinguish Issues from Pulls. (Q: Why not make that distinction during routing and call different functions?)
327
+ // Return 404 if feature is disabled.
328
+
325
329
isPullList := ctx .Params (":type" ) == "pulls"
326
330
unitType := models .UnitTypeIssues
327
331
if isPullList {
@@ -357,6 +361,13 @@ func Issues(ctx *context.Context) {
357
361
filterMode = models .FilterModeAll
358
362
)
359
363
364
+ // Distinguish User from Organization. Q: Again, why not distinguish during routing?
365
+ // Org:
366
+ // - Remember pre-determined string for later. Will be posted to ctx.Data.
367
+ // User:
368
+ // - Use ctx.Query("type") to determine filterMode. Q: Can there even be different values in ctx.Query("type")? How?
369
+ // - Remember either this or a fallback. Will be posted to ctx.Data.
370
+
360
371
if ctxUser .IsOrganization () {
361
372
viewType = "your_repositories"
362
373
} else {
@@ -374,11 +385,14 @@ func Issues(ctx *context.Context) {
374
385
}
375
386
}
376
387
388
+ // Make sure page number is at least 1. Will be posted to ctx.Data.
377
389
page := ctx .QueryInt ("page" )
378
390
if page <= 1 {
379
391
page = 1
380
392
}
381
393
394
+ // Parse ctx.Query("repos") and remember matched repo IDs for later.
395
+ // Q: Where can ctx.Query("repos") be filled? With the given routing, where can a value come from?
382
396
reposQuery := ctx .Query ("repos" )
383
397
var repoIDs []int64
384
398
if len (reposQuery ) != 0 {
@@ -400,9 +414,11 @@ func Issues(ctx *context.Context) {
400
414
}
401
415
}
402
416
417
+ // No idea what this means.
403
418
isShowClosed := ctx .Query ("state" ) == "closed"
404
419
405
- // Get repositories.
420
+ // Get repository IDs where User/Org has access.
421
+ // Again, the distinction between User and Org could perhaps be handled more elegantly.
406
422
var err error
407
423
var userRepoIDs []int64
408
424
if ctxUser .IsOrganization () {
@@ -432,6 +448,8 @@ func Issues(ctx *context.Context) {
432
448
userRepoIDs = []int64 {- 1 }
433
449
}
434
450
451
+ // Build IssuesOptions, which contains filter information.
452
+
435
453
opts := & models.IssuesOptions {
436
454
IsPull : util .OptionalBoolOf (isPullList ),
437
455
SortType : sortType ,
@@ -448,7 +466,11 @@ func Issues(ctx *context.Context) {
448
466
opts .MentionedID = ctxUser .ID
449
467
}
450
468
469
+ // Execute keyword search for issues.
470
+
471
+ // Ensure issue list is emtpy if keyword search didn't produce any results.
451
472
var forceEmpty bool
473
+ // Required for IssuesOptions.
452
474
var issueIDsFromSearch []int64
453
475
var keyword = strings .Trim (ctx .Query ("q" ), " " )
454
476
@@ -474,6 +496,7 @@ func Issues(ctx *context.Context) {
474
496
475
497
opts .IsClosed = util .OptionalBoolOf (isShowClosed )
476
498
499
+ // Filter repos and count issues in them. Count will be used later.
477
500
var counts map [int64 ]int64
478
501
if ! forceEmpty {
479
502
counts , err = models .CountIssuesByRepo (opts )
@@ -485,6 +508,9 @@ func Issues(ctx *context.Context) {
485
508
486
509
opts .Page = page
487
510
opts .PageSize = setting .UI .IssuePagingNum
511
+
512
+ // Get IDs for labels. Q: What are labels? Where do they come from?
513
+ // Required for IssuesOptions.
488
514
var labelIDs []int64
489
515
selectLabels := ctx .Query ("labels" )
490
516
if len (selectLabels ) > 0 && selectLabels != "0" {
@@ -500,6 +526,7 @@ func Issues(ctx *context.Context) {
500
526
opts .RepoIDs = repoIDs
501
527
}
502
528
529
+ // Get issues as defined by opts.
503
530
var issues []* models.Issue
504
531
if ! forceEmpty {
505
532
issues , err = models .Issues (opts )
@@ -517,6 +544,7 @@ func Issues(ctx *context.Context) {
517
544
return
518
545
}
519
546
547
+ // showReposMap maps repository IDs to their Repository pointers.
520
548
showReposMap := make (map [int64 ]* models.Repository , len (counts ))
521
549
for repoID := range counts {
522
550
if repoID > 0 {
@@ -545,13 +573,15 @@ func Issues(ctx *context.Context) {
545
573
}
546
574
}
547
575
576
+ // a RepositoryList
548
577
showRepos := models .RepositoryListOfMap (showReposMap )
549
578
sort .Sort (showRepos )
550
579
if err = showRepos .LoadAttributes (); err != nil {
551
580
ctx .ServerError ("LoadAttributes" , err )
552
581
return
553
582
}
554
583
584
+ // maps pull request IDs to their CommitStatus. Will be posted to ctx.Data.
555
585
var commitStatus = make (map [int64 ]* models.CommitStatus , len (issues ))
556
586
for _ , issue := range issues {
557
587
issue .Repo = showReposMap [issue .RepoID ]
@@ -571,12 +601,15 @@ func Issues(ctx *context.Context) {
571
601
if len (repoIDs ) > 0 {
572
602
userIssueStatsOpts .UserRepoIDs = repoIDs
573
603
}
604
+
605
+ // Will be posted to ctx.Data.
574
606
userIssueStats , err := models .GetUserIssueStats (userIssueStatsOpts )
575
607
if err != nil {
576
608
ctx .ServerError ("GetUserIssueStats User" , err )
577
609
return
578
610
}
579
611
612
+ // Will be posted to ctx.Data.
580
613
var shownIssueStats * models.IssueStats
581
614
if ! forceEmpty {
582
615
statsOpts := models.UserIssueStatsOptions {
@@ -599,6 +632,7 @@ func Issues(ctx *context.Context) {
599
632
shownIssueStats = & models.IssueStats {}
600
633
}
601
634
635
+ // Will be posted to ctx.Data.
602
636
var allIssueStats * models.IssueStats
603
637
if ! forceEmpty {
604
638
allIssueStats , err = models .GetUserIssueStats (models.UserIssueStatsOptions {
@@ -617,6 +651,7 @@ func Issues(ctx *context.Context) {
617
651
allIssueStats = & models.IssueStats {}
618
652
}
619
653
654
+ // Will be posted to ctx.Data.
620
655
var shownIssues int
621
656
var totalIssues int
622
657
if ! isShowClosed {
0 commit comments