@@ -452,13 +452,10 @@ func GetFeeds(ctx context.Context, opts GetFeedsOptions) (ActionList, int64, err
452
452
453
453
actions := make ([]* Action , 0 , opts .PageSize )
454
454
var count int64
455
+ opts .SetDefaultValues ()
455
456
456
457
if opts .Page < 10 { // TODO: why it's 10 but other values? It's an experience value.
457
- sess := db .GetEngine (ctx ).Where (cond ).
458
- Select ("`action`.*" ). // this line will avoid select other joined table's columns
459
- Join ("INNER" , "repository" , "`repository`.id = `action`.repo_id" )
460
-
461
- opts .SetDefaultValues ()
458
+ sess := db .GetEngine (ctx ).Where (cond )
462
459
sess = db .SetSessionPagination (sess , & opts )
463
460
464
461
count , err = sess .Desc ("`action`.created_unix" ).FindAndCount (& actions )
@@ -467,11 +464,7 @@ func GetFeeds(ctx context.Context, opts GetFeedsOptions) (ActionList, int64, err
467
464
}
468
465
} else {
469
466
// First, only query which IDs are necessary, and only then query all actions to speed up the overall query
470
- sess := db .GetEngine (ctx ).Where (cond ).
471
- Select ("`action`.id" ).
472
- Join ("INNER" , "repository" , "`repository`.id = `action`.repo_id" )
473
-
474
- opts .SetDefaultValues ()
467
+ sess := db .GetEngine (ctx ).Where (cond ).Select ("`action`.id" )
475
468
sess = db .SetSessionPagination (sess , & opts )
476
469
477
470
actionIDs := make ([]int64 , 0 , opts .PageSize )
@@ -481,8 +474,7 @@ func GetFeeds(ctx context.Context, opts GetFeedsOptions) (ActionList, int64, err
481
474
482
475
count , err = db .GetEngine (ctx ).Where (cond ).
483
476
Table ("action" ).
484
- Cols ("`action`.id" ).
485
- Join ("INNER" , "repository" , "`repository`.id = `action`.repo_id" ).Count ()
477
+ Cols ("`action`.id" ).Count ()
486
478
if err != nil {
487
479
return nil , 0 , fmt .Errorf ("Count: %w" , err )
488
480
}
0 commit comments