@@ -452,13 +452,10 @@ func GetFeeds(ctx context.Context, opts GetFeedsOptions) (ActionList, int64, err
452452
453453	actions  :=  make ([]* Action , 0 , opts .PageSize )
454454	var  count  int64 
455+ 	opts .SetDefaultValues ()
455456
456457	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 )
462459		sess  =  db .SetSessionPagination (sess , & opts )
463460
464461		count , err  =  sess .Desc ("`action`.created_unix" ).FindAndCount (& actions )
@@ -467,11 +464,7 @@ func GetFeeds(ctx context.Context, opts GetFeedsOptions) (ActionList, int64, err
467464		}
468465	} else  {
469466		// 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" )
475468		sess  =  db .SetSessionPagination (sess , & opts )
476469
477470		actionIDs  :=  make ([]int64 , 0 , opts .PageSize )
@@ -481,8 +474,7 @@ func GetFeeds(ctx context.Context, opts GetFeedsOptions) (ActionList, int64, err
481474
482475		count , err  =  db .GetEngine (ctx ).Where (cond ).
483476			Table ("action" ).
484- 			Cols ("`action`.id" ).
485- 			Join ("INNER" , "repository" , "`repository`.id = `action`.repo_id" ).Count ()
477+ 			Cols ("`action`.id" ).Count ()
486478		if  err  !=  nil  {
487479			return  nil , 0 , fmt .Errorf ("Count: %w" , err )
488480		}
0 commit comments