add last modified filter chip (#7455)

* add last modified filter chip

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

---------

Co-authored-by: Roman Perekhod <rperekhod@owncloud.com>
This commit is contained in:
Roman Perekhod
2023-10-19 18:25:01 +02:00
committed by GitHub
co-authored by Roman Perekhod
parent b436e49f19
commit acfae80b53
6 changed files with 423 additions and 267 deletions
@@ -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,
+10
View File
@@ -104,6 +104,13 @@ 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()
@@ -111,6 +118,9 @@ func toTimeRange(in interface{}) (*time.Time, *time.Time, error) {
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()
@@ -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
File diff suppressed because it is too large Load Diff
@@ -606,6 +606,50 @@ func TestParse_DateTimeRestrictionNode(t *testing.T) {
},
},
},
{
name: "NaturalLanguage DateTimeNode - last week",
patch: setWorldClock(t, "2023-09-06"),
query: join([]string{
`Mtime:"last week"`,
}),
ast: &ast.Ast{
Nodes: []ast.Node{
&ast.DateTimeNode{
Key: "Mtime",
Operator: &ast.OperatorNode{Value: ">="},
Value: mustParseTime(t, "2023-08-28"),
},
&ast.OperatorNode{Value: kql.BoolAND},
&ast.DateTimeNode{
Key: "Mtime",
Operator: &ast.OperatorNode{Value: "<="},
Value: mustParseTime(t, "2023-09-03 23:59:59.999999999"),
},
},
},
},
{
name: "NaturalLanguage DateTimeNode - last 7 days",
patch: setWorldClock(t, "2023-09-06"),
query: join([]string{
`Mtime:"last 7 days"`,
}),
ast: &ast.Ast{
Nodes: []ast.Node{
&ast.DateTimeNode{
Key: "Mtime",
Operator: &ast.OperatorNode{Value: ">="},
Value: mustParseTime(t, "2023-08-31"),
},
&ast.OperatorNode{Value: kql.BoolAND},
&ast.DateTimeNode{
Key: "Mtime",
Operator: &ast.OperatorNode{Value: "<="},
Value: mustParseTime(t, "2023-09-06 23:59:59.999999999"),
},
},
},
},
{
name: "NaturalLanguage DateTimeNode - this month",
patch: setWorldClock(t, "2023-09-02"),
@@ -672,6 +716,28 @@ func TestParse_DateTimeRestrictionNode(t *testing.T) {
},
},
},
{
name: "NaturalLanguage DateTimeNode - last 30 days",
patch: setWorldClock(t, "2023-09-06"),
query: join([]string{
`Mtime:"last 30 days"`,
}),
ast: &ast.Ast{
Nodes: []ast.Node{
&ast.DateTimeNode{
Key: "Mtime",
Operator: &ast.OperatorNode{Value: ">="},
Value: mustParseTime(t, "2023-08-08"),
},
&ast.OperatorNode{Value: kql.BoolAND},
&ast.DateTimeNode{
Key: "Mtime",
Operator: &ast.OperatorNode{Value: "<="},
Value: mustParseTime(t, "2023-09-06 23:59:59.999999999"),
},
},
},
},
{
name: "NaturalLanguage DateTimeNode - this year",
patch: setWorldClock(t, "2023-06-18"),