Allow dismissed filter parameter for dal schema alterations

This commit is contained in:
Tomaž Jerman
2023-10-26 17:09:59 +02:00
parent 6b7a6a5896
commit e852e7bcf1
3 changed files with 24 additions and 0 deletions
+3
View File
@@ -943,6 +943,9 @@ endpoints:
- name: completed
title: Exclude (0, default), include (1) or return only (2) completed alterations
type: uint
- name: dismissed
title: Exclude (0, default), include (1) or return only (2) dismissed alterations
type: uint
- type: bool
name: incTotal
title: Include total counter
@@ -64,6 +64,7 @@ func (ctrl DalSchemaAlteration) List(ctx context.Context, r *request.DalSchemaAl
Kind: r.Kind,
Deleted: filter.State(r.Deleted),
Dismissed: filter.State(r.Dismissed),
Completed: filter.State(r.Completed),
}
)
@@ -71,6 +72,9 @@ func (ctrl DalSchemaAlteration) List(ctx context.Context, r *request.DalSchemaAl
if f.Deleted == 0 {
f.Deleted = filter.StateExcluded
}
if f.Dismissed == 0 {
f.Dismissed = filter.StateExcluded
}
if f.Completed == 0 {
f.Completed = filter.StateExcluded
}
@@ -59,6 +59,11 @@ type (
// Exclude (0, default), include (1) or return only (2) completed alterations
Completed uint
// Dismissed GET parameter
//
// Exclude (0, default), include (1) or return only (2) dismissed alterations
Dismissed uint
// IncTotal GET parameter
//
// Include total counter
@@ -100,6 +105,7 @@ func (r DalSchemaAlterationList) Auditable() map[string]interface{} {
"kind": r.Kind,
"deleted": r.Deleted,
"completed": r.Completed,
"dismissed": r.Dismissed,
"incTotal": r.IncTotal,
}
}
@@ -129,6 +135,11 @@ func (r DalSchemaAlterationList) GetCompleted() uint {
return r.Completed
}
// Auditable returns all auditable/loggable parameters
func (r DalSchemaAlterationList) GetDismissed() uint {
return r.Dismissed
}
// Auditable returns all auditable/loggable parameters
func (r DalSchemaAlterationList) GetIncTotal() bool {
return r.IncTotal
@@ -176,6 +187,12 @@ func (r *DalSchemaAlterationList) Fill(req *http.Request) (err error) {
return err
}
}
if val, ok := tmp["dismissed"]; ok && len(val) > 0 {
r.Dismissed, err = payload.ParseUint(val[0]), nil
if err != nil {
return err
}
}
if val, ok := tmp["incTotal"]; ok && len(val) > 0 {
r.IncTotal, err = payload.ParseBool(val[0]), nil
if err != nil {