Skip to content

Commit 98deb76

Browse files
recordstore/filter: Convert int64 param to any underlying int variation (#90)
* recordstore/filter: Change from int param to any underlying int (variations) type * add int8 and int16
1 parent f648db8 commit 98deb76

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

adapters/adaptertest/recordstore.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ func testList(t *testing.T, factory func() workflow.RecordStore) {
237237
0,
238238
100,
239239
workflow.OrderTypeAscending,
240-
workflow.FilterByStatus(int64(status)),
240+
workflow.FilterByStatus(status),
241241
)
242242
require.Nil(t, err)
243243
require.Equal(t, count, len(ls))
@@ -360,7 +360,7 @@ func testList(t *testing.T, factory func() workflow.RecordStore) {
360360
0,
361361
100,
362362
workflow.OrderTypeAscending,
363-
workflow.FilterByStatus(int64(status)),
363+
workflow.FilterByStatus(status),
364364
)
365365
require.Nil(t, err)
366366
require.Equal(t, count, len(ls))

adapters/webui/internal/api/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func List(listRecords ListWorkflowRecords, stringer Stringer) http.HandlerFunc {
6767
}
6868

6969
if req.FilterByStatus != 0 {
70-
filters = append(filters, workflow.FilterByStatus(int64(req.FilterByStatus)))
70+
filters = append(filters, workflow.FilterByStatus(req.FilterByStatus))
7171
}
7272

7373
list, err := listRecords(r.Context(), req.WorkflowName, req.Offset, req.Limit, order, filters...)

filter.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package workflow
22

3-
import "strconv"
3+
import (
4+
"strconv"
5+
)
46

57
func MakeFilter(filters ...RecordFilter) *recordFilters {
68
var rf recordFilters
@@ -49,9 +51,9 @@ func FilterByForeignID(val string) RecordFilter {
4951
}
5052
}
5153

52-
func FilterByStatus(status int64) RecordFilter {
54+
func FilterByStatus[statusType ~int | ~int8 | ~int16 | ~int32 | ~int64](status statusType) RecordFilter {
5355
return func(filters *recordFilters) {
54-
i := strconv.FormatInt(status, 10)
56+
i := strconv.FormatInt(int64(status), 10)
5557
filters.byStatus = makeFilterValue(i)
5658
}
5759
}

0 commit comments

Comments
 (0)