Skip to content

Commit

Permalink
/api/audit-recovery supports "unacknowledged=true" query param filter
Browse files Browse the repository at this point in the history
  • Loading branch information
shlomi-noach committed Oct 27, 2015
1 parent 85588c6 commit f482d3b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
set -e

RELEASE_VERSION="1.4.468"
RELEASE_VERSION="1.4.469"
TOPDIR=/tmp/orchestrator-release
export RELEASE_VERSION TOPDIR

Expand Down
3 changes: 2 additions & 1 deletion go/http/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1890,7 +1890,8 @@ func (this *HttpAPI) AuditRecovery(params martini.Params, r render.Render, req *
if err != nil || page < 0 {
page = 0
}
audits, err := logic.ReadRecentRecoveries(params["clusterName"], page)
unacknowledgedOnly := (req.URL.Query().Get("unacknowledged") == "true")
audits, err := logic.ReadRecentRecoveries(params["clusterName"], unacknowledgedOnly, page)

if err != nil {
r.JSON(200, &APIResponse{Code: ERROR, Message: fmt.Sprintf("%+v", err)})
Expand Down
14 changes: 9 additions & 5 deletions go/logic/topology_recovery_dao.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,13 +485,17 @@ func ReadCompletedRecoveries(page int) ([]TopologyRecovery, error) {
}

// ReadCRecoveries reads latest recovery entries from topology_recovery
func ReadRecentRecoveries(clusterName string, page int) ([]TopologyRecovery, error) {
func ReadRecentRecoveries(clusterName string, unacknowledgedOnly bool, page int) ([]TopologyRecovery, error) {
whereConditions := []string{}
whereClause := ""
if unacknowledgedOnly {
whereConditions = append(whereConditions, `acknowledged=0`)
}
if clusterName != "" {
whereClause = fmt.Sprintf(`
where
cluster_name='%s'`,
clusterName)
whereConditions = append(whereConditions, fmt.Sprintf(`cluster_name='%s'`, clusterName))
}
if len(whereConditions) > 0 {
whereClause = fmt.Sprintf("where %s", strings.Join(whereConditions, " and "))
}
limit := fmt.Sprintf(`
limit %d
Expand Down

0 comments on commit f482d3b

Please sign in to comment.