@@ -454,6 +454,24 @@ func ActivityReadable(user, doer *user_model.User) bool {
454454 doer != nil && (doer .IsAdmin || user .ID == doer .ID )
455455}
456456
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+
457475func ActivityQueryCondition (ctx context.Context , opts GetFeedsOptions ) (builder.Cond , error ) {
458476 cond := builder .NewCond ()
459477
@@ -534,17 +552,7 @@ func ActivityQueryCondition(ctx context.Context, opts GetFeedsOptions) (builder.
534552 cond = cond .And (builder.Eq {"is_deleted" : false })
535553 }
536554
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 ))
548556
549557 return cond , nil
550558}
0 commit comments