Task filters (#243)
Fix not returning errors Fix integration tests Add more tests Make task filtering actually work Change tests Fix using filter conditions Fix test Remove unused fields Fix static check Remove start and end date fields on task collection Fix misspell add filter logic when getting tasks Add parsing filter query parameters into task filters Start adding support for filters Co-authored-by: kolaente <k@knt.li> Reviewed-on: https://kolaente.dev/vikunja/api/pulls/243
This commit is contained in:
9
vendor/github.com/iancoleman/strcase/.travis.yml
generated
vendored
Normal file
9
vendor/github.com/iancoleman/strcase/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
sudo: false
|
||||
language: go
|
||||
go:
|
||||
- 1.7.x
|
||||
- 1.8.x
|
||||
- 1.9.x
|
||||
- 1.10.x
|
||||
- 1.11.x
|
||||
- master
|
22
vendor/github.com/iancoleman/strcase/LICENSE
generated
vendored
Normal file
22
vendor/github.com/iancoleman/strcase/LICENSE
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Ian Coleman
|
||||
Copyright (c) 2018 Ma_124, <github.com/Ma124>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, Subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or Substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
33
vendor/github.com/iancoleman/strcase/README.md
generated
vendored
Normal file
33
vendor/github.com/iancoleman/strcase/README.md
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
# strcase
|
||||
[](http://godoc.org/github.com/iancoleman/strcase)
|
||||
[](https://travis-ci.org/iancoleman/strcase)
|
||||
[](http://gocover.io/github.com/iancoleman/strcase)
|
||||
[](https://goreportcard.com/report/github.com/iancoleman/strcase)
|
||||
|
||||
strcase is a go package for converting string case to various cases (e.g. [snake case](https://en.wikipedia.org/wiki/Snake_case) or [camel case](https://en.wikipedia.org/wiki/CamelCase)) to see the full conversion table below.
|
||||
|
||||
## Example
|
||||
|
||||
```go
|
||||
s := "AnyKind of_string"
|
||||
```
|
||||
|
||||
| Function | Result |
|
||||
|-------------------------------------------|----------------------|
|
||||
| `ToSnake(s)` | `any_kind_of_string` |
|
||||
| `ToSnakeWithIgnore(s, '.')` | `any_kind.of_string` |
|
||||
| `ToScreamingSnake(s)` | `ANY_KIND_OF_STRING` |
|
||||
| `ToKebab(s)` | `any-kind-of-string` |
|
||||
| `ToScreamingKebab(s)` | `ANY-KIND-OF-STRING` |
|
||||
| `ToDelimited(s, '.')` | `any.kind.of.string` |
|
||||
| `ToScreamingDelimited(s, '.', '', true)` | `ANY.KIND.OF.STRING` |
|
||||
| `ToScreamingDelimited(s, '.', ' ', true)` | `ANY.KIND OF.STRING` |
|
||||
| `ToCamel(s)` | `AnyKindOfString` |
|
||||
| `ToLowerCamel(s)` | `anyKindOfString` |
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
go get -u github.com/iancoleman/strcase
|
||||
```
|
5
vendor/github.com/iancoleman/strcase/acronyms.go
generated
vendored
Normal file
5
vendor/github.com/iancoleman/strcase/acronyms.go
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
package strcase
|
||||
|
||||
var uppercaseAcronym = map[string]bool{
|
||||
"ID": true,
|
||||
}
|
81
vendor/github.com/iancoleman/strcase/camel.go
generated
vendored
Normal file
81
vendor/github.com/iancoleman/strcase/camel.go
generated
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2015 Ian Coleman
|
||||
* Copyright (c) 2018 Ma_124, <github.com/Ma124>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, Subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or Substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package strcase
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Converts a string to CamelCase
|
||||
func toCamelInitCase(s string, initCase bool) string {
|
||||
s = addWordBoundariesToNumbers(s)
|
||||
s = strings.Trim(s, " ")
|
||||
n := ""
|
||||
capNext := initCase
|
||||
for _, v := range s {
|
||||
if v >= 'A' && v <= 'Z' {
|
||||
n += string(v)
|
||||
}
|
||||
if v >= '0' && v <= '9' {
|
||||
n += string(v)
|
||||
}
|
||||
if v >= 'a' && v <= 'z' {
|
||||
if capNext {
|
||||
n += strings.ToUpper(string(v))
|
||||
} else {
|
||||
n += string(v)
|
||||
}
|
||||
}
|
||||
if v == '_' || v == ' ' || v == '-' || v == '.' {
|
||||
capNext = true
|
||||
} else {
|
||||
capNext = false
|
||||
}
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
// ToCamel converts a string to CamelCase
|
||||
func ToCamel(s string) string {
|
||||
if uppercaseAcronym[s] {
|
||||
s = strings.ToLower(s)
|
||||
}
|
||||
return toCamelInitCase(s, true)
|
||||
}
|
||||
|
||||
// ToLowerCamel converts a string to lowerCamelCase
|
||||
func ToLowerCamel(s string) string {
|
||||
if s == "" {
|
||||
return s
|
||||
}
|
||||
if uppercaseAcronym[s] {
|
||||
s = strings.ToLower(s)
|
||||
}
|
||||
if r := rune(s[0]); r >= 'A' && r <= 'Z' {
|
||||
s = strings.ToLower(string(r)) + s[1:]
|
||||
}
|
||||
return toCamelInitCase(s, false)
|
||||
}
|
12
vendor/github.com/iancoleman/strcase/doc.go
generated
vendored
Normal file
12
vendor/github.com/iancoleman/strcase/doc.go
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
// Package strcase converts strings to various cases. See the conversion table below:
|
||||
// | Function | Result |
|
||||
// |---------------------------------|--------------------|
|
||||
// | ToSnake(s) | any_kind_of_string |
|
||||
// | ToScreamingSnake(s) | ANY_KIND_OF_STRING |
|
||||
// | ToKebab(s) | any-kind-of-string |
|
||||
// | ToScreamingKebab(s) | ANY-KIND-OF-STRING |
|
||||
// | ToDelimited(s, '.') | any.kind.of.string |
|
||||
// | ToScreamingDelimited(s, '.') | ANY.KIND.OF.STRING |
|
||||
// | ToCamel(s) | AnyKindOfString |
|
||||
// | ToLowerCamel(s) | anyKindOfString |
|
||||
package strcase
|
38
vendor/github.com/iancoleman/strcase/numbers.go
generated
vendored
Normal file
38
vendor/github.com/iancoleman/strcase/numbers.go
generated
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2015 Ian Coleman
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, Subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or Substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package strcase
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
)
|
||||
|
||||
var numberSequence = regexp.MustCompile(`([a-zA-Z])(\d+)([a-zA-Z]?)`)
|
||||
var numberReplacement = []byte(`$1 $2 $3`)
|
||||
|
||||
func addWordBoundariesToNumbers(s string) string {
|
||||
b := []byte(s)
|
||||
b = numberSequence.ReplaceAll(b, numberReplacement)
|
||||
return string(b)
|
||||
}
|
113
vendor/github.com/iancoleman/strcase/snake.go
generated
vendored
Normal file
113
vendor/github.com/iancoleman/strcase/snake.go
generated
vendored
Normal file
@ -0,0 +1,113 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2015 Ian Coleman
|
||||
* Copyright (c) 2018 Ma_124, <github.com/Ma124>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, Subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or Substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package strcase
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// ToSnake converts a string to snake_case
|
||||
func ToSnake(s string) string {
|
||||
|
||||
return ToDelimited(s, '_')
|
||||
}
|
||||
func ToSnakeWithIgnore(s string, ignore uint8) string {
|
||||
|
||||
return ToScreamingDelimited(s, '_', ignore, false)
|
||||
}
|
||||
|
||||
// ToScreamingSnake converts a string to SCREAMING_SNAKE_CASE
|
||||
func ToScreamingSnake(s string) string {
|
||||
return ToScreamingDelimited(s, '_', 0, true)
|
||||
}
|
||||
|
||||
// ToKebab converts a string to kebab-case
|
||||
func ToKebab(s string) string {
|
||||
return ToDelimited(s, '-')
|
||||
}
|
||||
|
||||
// ToScreamingKebab converts a string to SCREAMING-KEBAB-CASE
|
||||
func ToScreamingKebab(s string) string {
|
||||
return ToScreamingDelimited(s, '-', 0, true)
|
||||
}
|
||||
|
||||
// ToDelimited converts a string to delimited.snake.case
|
||||
// (in this case `delimiter = '.'`)
|
||||
func ToDelimited(s string, delimiter uint8) string {
|
||||
return ToScreamingDelimited(s, delimiter, 0, false)
|
||||
}
|
||||
|
||||
// ToScreamingDelimited converts a string to SCREAMING.DELIMITED.SNAKE.CASE
|
||||
// (in this case `delimiter = '.'; screaming = true`)
|
||||
// or delimited.snake.case
|
||||
// (in this case `delimiter = '.'; screaming = false`)
|
||||
func ToScreamingDelimited(s string, delimiter uint8, ignore uint8, screaming bool) string {
|
||||
s = addWordBoundariesToNumbers(s)
|
||||
s = strings.Trim(s, " ")
|
||||
n := ""
|
||||
for i, v := range s {
|
||||
// treat acronyms as words, eg for JSONData -> JSON is a whole word
|
||||
nextCaseIsChanged := false
|
||||
if i+1 < len(s) {
|
||||
next := s[i+1]
|
||||
vIsCap := v >= 'A' && v <= 'Z'
|
||||
vIsLow := v >= 'a' && v <= 'z'
|
||||
nextIsCap := next >= 'A' && next <= 'Z'
|
||||
nextIsLow := next >= 'a' && next <= 'z'
|
||||
if (vIsCap && nextIsLow) || (vIsLow && nextIsCap) {
|
||||
nextCaseIsChanged = true
|
||||
}
|
||||
if ignore > 0 && i-1 >= 0 && s[i-1] == ignore && nextCaseIsChanged {
|
||||
nextCaseIsChanged = false
|
||||
}
|
||||
}
|
||||
|
||||
if i > 0 && n[len(n)-1] != delimiter && nextCaseIsChanged {
|
||||
// add underscore if next letter case type is changed
|
||||
if v >= 'A' && v <= 'Z' {
|
||||
n += string(delimiter) + string(v)
|
||||
} else if v >= 'a' && v <= 'z' {
|
||||
n += string(v) + string(delimiter)
|
||||
}
|
||||
} else if v == ' ' || v == '_' || v == '-' {
|
||||
// replace spaces/underscores with delimiters
|
||||
if uint8(v) == ignore {
|
||||
n += string(v)
|
||||
} else {
|
||||
n += string(delimiter)
|
||||
}
|
||||
} else {
|
||||
n = n + string(v)
|
||||
}
|
||||
}
|
||||
|
||||
if screaming {
|
||||
n = strings.ToUpper(n)
|
||||
} else {
|
||||
n = strings.ToLower(n)
|
||||
}
|
||||
return n
|
||||
}
|
Reference in New Issue
Block a user