-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: change grant ordering default to be EffectiveAt descending OM-…
…840 (#1253) * chore: change grant ordering default to be EffectiveAt descending * feat: add option to change order direction * style: fix lint * chore: use null value for sortx.Order
- Loading branch information
Showing
12 changed files
with
732 additions
and
544 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
api/client/python/src/openmeter/aio/_operations/_operations.py
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package entutils | ||
|
||
import ( | ||
"entgo.io/ent/dialect/sql" | ||
|
||
"github.com/openmeterio/openmeter/pkg/sortx" | ||
) | ||
|
||
func GetOrdering(order sortx.Order) []sql.OrderTermOption { | ||
type o = sql.OrderTermOption | ||
|
||
switch order { | ||
case sortx.OrderAsc: | ||
return []o{sql.OrderAsc()} | ||
case sortx.OrderDesc: | ||
return []o{sql.OrderDesc()} | ||
default: | ||
return getStrOrdering(string(order)) | ||
} | ||
} | ||
|
||
func getStrOrdering(order string) []sql.OrderTermOption { | ||
type o = sql.OrderTermOption | ||
|
||
switch order { | ||
case string(sortx.OrderAsc): | ||
return []o{sql.OrderAsc()} | ||
case string(sortx.OrderDesc): | ||
return []o{sql.OrderDesc()} | ||
default: | ||
return []o{} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package sortx | ||
|
||
type Order string | ||
|
||
const ( | ||
OrderAsc Order = "ASC" | ||
OrderDesc Order = "DESC" | ||
OrderDefault Order = "ASC" | ||
OrderNone Order = "" | ||
) | ||
|
||
func (s Order) String() string { | ||
return string(s) | ||
} | ||
|
||
func (s Order) IsDefaultValue() bool { | ||
return s == "" | ||
} |