Skip to content

Commit e862a5a

Browse files
authored
fix: rename hidden to archived (#875)
1 parent da8a8a9 commit e862a5a

File tree

5 files changed

+26
-19
lines changed

5 files changed

+26
-19
lines changed

api/docs.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3947,8 +3947,8 @@ const docTemplate = `{
39473947
},
39483948
{
39493949
"type": "boolean",
3950-
"description": "Is the account hidden?",
3951-
"name": "hidden",
3950+
"description": "Is the account archived?",
3951+
"name": "archived",
39523952
"in": "query"
39533953
},
39543954
{

api/swagger.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3936,8 +3936,8 @@
39363936
},
39373937
{
39383938
"type": "boolean",
3939-
"description": "Is the account hidden?",
3940-
"name": "hidden",
3939+
"description": "Is the account archived?",
3940+
"name": "archived",
39413941
"in": "query"
39423942
},
39433943
{

api/swagger.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4699,9 +4699,9 @@ paths:
46994699
in: query
47004700
name: external
47014701
type: boolean
4702-
- description: Is the account hidden?
4702+
- description: Is the account archived?
47034703
in: query
4704-
name: hidden
4704+
name: archived
47054705
type: boolean
47064706
- description: Search for this text in name and note
47074707
in: query

pkg/controllers/account_v3.go

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ func (a *AccountV3) links(c *gin.Context) {
5252
}
5353

5454
type AccountQueryFilterV3 struct {
55-
Name string `form:"name" filterField:"false"` // Fuzzy filter for the account name
56-
Note string `form:"note" filterField:"false"` // Fuzzy filter for the note
57-
BudgetID string `form:"budget"` // By budget ID
58-
OnBudget bool `form:"onBudget"` // Is the account on-budget?
59-
External bool `form:"external"` // Is the account external?
60-
Hidden bool `form:"hidden"` // Is the account hidden?
61-
Search string `form:"search" filterField:"false"` // By string in name or note
62-
Offset uint `form:"offset" filterField:"false"` // The offset of the first Transaction returned. Defaults to 0.
63-
Limit int `form:"limit" filterField:"false"` // Maximum number of transactions to return. Defaults to 50.
55+
Name string `form:"name" filterField:"false"` // Fuzzy filter for the account name
56+
Note string `form:"note" filterField:"false"` // Fuzzy filter for the note
57+
BudgetID string `form:"budget"` // By budget ID
58+
OnBudget bool `form:"onBudget"` // Is the account on-budget?
59+
External bool `form:"external"` // Is the account external?
60+
Archived bool `form:"archived" filterField:"false"` // Is the account hidden?
61+
Search string `form:"search" filterField:"false"` // By string in name or note
62+
Offset uint `form:"offset" filterField:"false"` // The offset of the first Transaction returned. Defaults to 0.
63+
Limit int `form:"limit" filterField:"false"` // Maximum number of transactions to return. Defaults to 50.
6464
}
6565

6666
func (f AccountQueryFilterV3) ToCreate() (models.AccountCreate, httperrors.Error) {
@@ -73,7 +73,7 @@ func (f AccountQueryFilterV3) ToCreate() (models.AccountCreate, httperrors.Error
7373
BudgetID: budgetID,
7474
OnBudget: f.OnBudget,
7575
External: f.External,
76-
Hidden: f.Hidden,
76+
Hidden: f.Archived,
7777
}, httperrors.Error{}
7878
}
7979

@@ -256,7 +256,7 @@ func (co Controller) CreateAccountsV3(c *gin.Context) {
256256
// @Param budget query string false "Filter by budget ID"
257257
// @Param onBudget query bool false "Is the account on-budget?"
258258
// @Param external query bool false "Is the account external?"
259-
// @Param hidden query bool false "Is the account hidden?"
259+
// @Param archived query bool false "Is the account archived?"
260260
// @Param search query string false "Search for this text in name and note"
261261
// @Param offset query uint false "The offset of the first Transaction returned. Defaults to 0."
262262
// @Param limit query int false "Maximum number of transactions to return. Defaults to 50."
@@ -270,6 +270,13 @@ func (co Controller) GetAccountsV3(c *gin.Context) {
270270
// Get the set parameters in the query string
271271
queryFields, setFields := httputil.GetURLFields(c.Request.URL, filter)
272272

273+
// If the archived parameter is set, add "Hidden" to the query fields
274+
// This is done since in v3, we're using the name "Archived", but the
275+
// field is not yet updated in the database, which will happen later
276+
if slices.Contains(setFields, "Archived") {
277+
queryFields = append(queryFields, "Hidden")
278+
}
279+
273280
// Convert the QueryFilter to a Create struct
274281
create, err := filter.ToCreate()
275282
if !err.Nil() {

pkg/controllers/account_v3_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ func (suite *TestSuiteStandard) TestAccountsV3GetFilter() {
196196
{"Off budget", "onBudget=false", 4},
197197
{"External", "external=true", 2},
198198
{"Internal", "external=false", 3},
199-
{"Not Hidden", "hidden=false", 3},
200-
{"Hidden", "hidden=true", 2},
199+
{"Not Archived", "archived=false", 3},
200+
{"Archived", "archived=true", 2},
201201
{"Search for 'na", "search=na", 3},
202202
{"Search for 'fi", "search=fi", 4},
203203
{"Offset 2", "offset=2", 3},

0 commit comments

Comments
 (0)