Skip to content

Commit

Permalink
add last modified filter chip (#7455)
Browse files Browse the repository at this point in the history
* add last modified filter chip

* Update add-last-modified-filter-chip.md

---------

Co-authored-by: Roman Perekhod <rperekhod@owncloud.com>
  • Loading branch information
2403905 and 2403905 committed Oct 19, 2023
1 parent b436e49 commit acfae80
Show file tree
Hide file tree
Showing 6 changed files with 355 additions and 199 deletions.
7 changes: 7 additions & 0 deletions changelog/unreleased/add-last-modified-filter-chip.md
@@ -0,0 +1,7 @@
Enhancement: Add "Last modified" filter Chip

Add "Last modified" filter Chip

https://github.com/owncloud/ocis/issues/7431
https://github.com/owncloud/ocis/pull/7455

52 changes: 52 additions & 0 deletions services/frontend/pkg/revaconfig/config.go
Expand Up @@ -289,6 +289,58 @@ 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{}{
{
"name": []map[string]interface{}{
{
"enabled": true,
},
},
"mtime": []map[string]interface{}{
{
"keywords": []string{"today", "yesterday", "this week", "last week", "last 7 days", "this month", "last month", "last 30 days", "this year", "last year"},
"enabled": true,
},
},
"size": []map[string]interface{}{
{
"enabled": false,
},
},
"mimetype": []map[string]interface{}{
{
"enabled": true,
},
},
"type": []map[string]interface{}{
{
"enabled": true,
},
},
"tag": []map[string]interface{}{
{
"enabled": true,
},
},
"tags": []map[string]interface{}{
{
"enabled": true,
},
},
"content": []map[string]interface{}{
{
"enabled": true,
},
},
"scope": []map[string]interface{}{
{
"enabled": true,
},
},
},
},
},
"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
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
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

0 comments on commit acfae80

Please sign in to comment.