@@ -454,6 +454,24 @@ func ActivityReadable(user, doer *user_model.User) bool {
454
454
doer != nil && (doer .IsAdmin || user .ID == doer .ID )
455
455
}
456
456
457
+ func FeedDateCond (opts GetFeedsOptions ) builder.Cond {
458
+ cond := builder .NewCond ()
459
+ if opts .Date == "" {
460
+ return cond
461
+ }
462
+
463
+ dateLow , err := time .ParseInLocation ("2006-01-02" , opts .Date , setting .DefaultUILocation )
464
+ if err != nil {
465
+ log .Warn ("Unable to parse %s, filter not applied: %v" , opts .Date , err )
466
+ } else {
467
+ dateHigh := dateLow .Add (86399000000000 ) // 23h59m59s
468
+
469
+ cond = cond .And (builder.Gte {"`action`.created_unix" : dateLow .Unix ()})
470
+ cond = cond .And (builder.Lte {"`action`.created_unix" : dateHigh .Unix ()})
471
+ }
472
+ return cond
473
+ }
474
+
457
475
func ActivityQueryCondition (ctx context.Context , opts GetFeedsOptions ) (builder.Cond , error ) {
458
476
cond := builder .NewCond ()
459
477
@@ -534,17 +552,7 @@ func ActivityQueryCondition(ctx context.Context, opts GetFeedsOptions) (builder.
534
552
cond = cond .And (builder.Eq {"is_deleted" : false })
535
553
}
536
554
537
- if opts .Date != "" {
538
- dateLow , err := time .ParseInLocation ("2006-01-02" , opts .Date , setting .DefaultUILocation )
539
- if err != nil {
540
- log .Warn ("Unable to parse %s, filter not applied: %v" , opts .Date , err )
541
- } else {
542
- dateHigh := dateLow .Add (86399000000000 ) // 23h59m59s
543
-
544
- cond = cond .And (builder.Gte {"`action`.created_unix" : dateLow .Unix ()})
545
- cond = cond .And (builder.Lte {"`action`.created_unix" : dateHigh .Unix ()})
546
- }
547
- }
555
+ cond = cond .And (FeedDateCond (opts ))
548
556
549
557
return cond , nil
550
558
}
0 commit comments