Skip to content

Commit

Permalink
add last modified filter chip
Browse files Browse the repository at this point in the history
  • Loading branch information
2403905 committed Oct 11, 2023
1 parent efafb64 commit 3711ae1
Show file tree
Hide file tree
Showing 6 changed files with 308 additions and 199 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/add-last-modified-filter-chip.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: Add "Last modified" filter Chip

Add "Last modified" filter Chip

https://github.com/owncloud/ocis/issues/7431
7 changes: 7 additions & 0 deletions services/frontend/pkg/revaconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,13 @@ func FrontendConfigFromStruct(cfg *config.Config, logger log.Logger) (map[string
"share_jail": cfg.EnableShareJail,
"max_quota": cfg.MaxQuota,
},
"search": map[string]interface{}{
"property": []map[string]interface{}{
{
"mtime": []string{"today", "yesterday", "this week", "last week", "last 7 days", "this month", "last month", "last 30 days", "this year", "last year"},
},
},
},
"password_policy": map[string]interface{}{
"max_characters": 72,
"min_characters": cfg.PasswordPolicy.MinCharacters,
Expand Down
10 changes: 10 additions & 0 deletions services/search/pkg/query/kql/cast.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,23 @@ func toTimeRange(in interface{}) (*time.Time, *time.Time, error) {
case "this week":
from = n.BeginningOfWeek()
to = n.EndOfWeek()
case "last week":
lastWeek := n.With(n.AddDate(0, 0, -7))
from = lastWeek.BeginningOfWeek()
to = lastWeek.EndOfWeek()
case "last 7 days":
from = n.With(n.AddDate(0, 0, -6)).BeginningOfDay()
to = n.EndOfDay()
case "this month":
from = n.BeginningOfMonth()
to = n.EndOfMonth()
case "last month":
lastMonth := n.With(n.AddDate(0, -1, 0))
from = lastMonth.BeginningOfMonth()
to = lastMonth.EndOfMonth()
case "last 30 days":
from = n.With(n.AddDate(0, 0, -29)).BeginningOfDay()
to = n.EndOfDay()
case "this year":
from = n.BeginningOfYear()
to = n.EndOfYear()
Expand Down
3 changes: 3 additions & 0 deletions services/search/pkg/query/kql/dictionary.peg
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,11 @@ NaturalLanguageDateTime <-
"today" /
"yesterday" /
"this week" /
"last week" /
"last 7 days" /
"this month" /
"last month" /
"last 30 days" /
"this year" /
"last year" {
return c.text, nil
Expand Down
Loading

0 comments on commit 3711ae1

Please sign in to comment.