Skip to content

Commit e542c8c

Browse files
committed
feat: add filtering for hidden categories
1 parent 3a65cc5 commit e542c8c

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

pkg/controllers/category.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ type CategoryQueryFilter struct {
3535
Name string `form:"name" filterField:"false"`
3636
BudgetID string `form:"budget"`
3737
Note string `form:"note" filterField:"false"`
38+
Hidden bool `form:"hidden"`
3839
}
3940

4041
func (f CategoryQueryFilter) ToCreate(c *gin.Context) (models.CategoryCreate, bool) {
@@ -45,6 +46,7 @@ func (f CategoryQueryFilter) ToCreate(c *gin.Context) (models.CategoryCreate, bo
4546

4647
return models.CategoryCreate{
4748
BudgetID: budgetID,
49+
Hidden: f.Hidden,
4850
}, true
4951
}
5052

pkg/controllers/category_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ func (suite *TestSuiteStandard) TestGetCategoriesFilter() {
125125
Name: "Category Name",
126126
Note: "A note for this category",
127127
BudgetID: b1.Data.ID,
128+
Hidden: true,
128129
})
129130

130131
_ = suite.createTestCategory(models.CategoryCreate{
@@ -153,6 +154,8 @@ func (suite *TestSuiteStandard) TestGetCategoriesFilter() {
153154
{"Fuzzy name", "name=t", 2},
154155
{"Fuzzy note, no name", "name=&note=Groceries", 0},
155156
{"Fuzzy note", "note=Groceries", 2},
157+
{"Not hidden", "hidden=false", 2},
158+
{"Hidden", "hidden=true", 1},
156159
}
157160

158161
for _, tt := range tests {

0 commit comments

Comments
 (0)