Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Batch acceptance and finalization of decisions #415

Open
wants to merge 3 commits into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
169 changes: 169 additions & 0 deletions documentation/docs/reference/services/Decision.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,91 @@ Response format:
}
```

POST /decision/batch/
--------------------------

Updates the decision for each of the users as specified in the `id` field of each of the decisions. The list of updated decisions is returned in the response.

**Batched version of the above.**

Request format:
```
{
"decisions": [
{
"id": "github9279532",
"status": "ACCEPTED",
"wave": 1
},
{
"id": "github1234567",
"status": "ACCEPTED",
"wave": 1
}
]
}
```

Response format:
```
{
"decisions": [
{
"finalized": false,
"id": "github9279532",
"status": "ACCEPTED",
"wave": 1,
"reviewer": "github9279532",
"timestamp": 1526673862,
"history": [
{
"finalized": false,
"id": "github9279532",
"status": "PENDING",
"wave": 0,
"reviewer": "github9279532",
"timestamp": 1526673845
},
{
"finalized": true,
"id": "github9279532",
"status": "ACCEPTED",
"wave": 1,
"reviewer": "github9279532",
"timestamp": 1526673862
}
]
},
{
"finalized": false,
"id": "github1234567",
"status": "ACCEPTED",
"wave": 1,
"reviewer": "github9279532",
"timestamp": 1526673862,
"history": [
{
"finalized": false,
"id": "github1234567",
"status": "PENDING",
"wave": 0,
"reviewer": "github9279532",
"timestamp": 1526673845
},
{
"finalized": true,
"id": "github1234567",
"status": "ACCEPTED",
"wave": 1,
"reviewer": "github9279532",
"timestamp": 1526673862
}
]
}
]
}
```

POST /decision/finalize/
--------------------------

Expand Down Expand Up @@ -144,6 +229,90 @@ Response format:

}
```

POST /decision/finalize/batch/
--------------------------

Finalizes / unfinalizes the decisions for the list of provided users. The full decision history is returned in the response. This endpoint will return an AttributeMismatchError if the requested action results in a Finalized status matching the current Finalized status.

**Batched version of the above.**

Request format:
```
{
"decisions:", [
{
"id": "github9279532",
"finalized": true
},
{
"id": "github1234567",
"finalized": true
}
]
}
```

Response format:
```
{
"decisions": [
{
"finalized": true,
"id": "github9279532",
"status": "ACCEPTED",
"wave": 1,
"reviewer": "github9279532",
"timestamp": 1526673862,
"history": [
{
"finalized": false,
"id": "github9279532",
"status": "PENDING",
"wave": 0,
"reviewer": "github9279532",
"timestamp": 1526673845
},
{
"finalized": true,
"id": "github9279532",
"status": "ACCEPTED",
"wave": 1,
"reviewer": "github9279532",
"timestamp": 1526673862
}
]
},
{
"finalized": true,
"id": "github1234567",
"status": "ACCEPTED",
"wave": 1,
"reviewer": "github9279532",
"timestamp": 1526673862,
"history": [
{
"finalized": false,
"id": "github1234567",
"status": "PENDING",
"wave": 0,
"reviewer": "github9279532",
"timestamp": 1526673845
},
{
"finalized": true,
"id": "github1234567",
"status": "ACCEPTED",
"wave": 1,
"reviewer": "github9279532",
"timestamp": 1526673862
}
]
}
]
}
```

GET /decision/filter/?key=value
----------------------------------

Expand Down
20 changes: 20 additions & 0 deletions gateway/services/decision.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ var DecisionRoutes = arbor.RouteCollection{
"/decision/",
alice.New(middleware.AuthMiddleware([]models.Role{models.AdminRole, models.StaffRole}), middleware.IdentificationMiddleware).ThenFunc(UpdateDecision).ServeHTTP,
},
arbor.Route{
"UpdateDecisionBatch",
"POST",
"/decision/batch/",
alice.New(middleware.AuthMiddleware([]models.Role{models.AdminRole, models.StaffRole}), middleware.IdentificationMiddleware).ThenFunc(UpdateDecisionBatch).ServeHTTP,
},
arbor.Route{
"GetFilteredDecisions",
"GET",
Expand All @@ -37,6 +43,12 @@ var DecisionRoutes = arbor.RouteCollection{
"/decision/finalize/",
alice.New(middleware.AuthMiddleware([]models.Role{models.AdminRole}), middleware.IdentificationMiddleware).ThenFunc(FinalizeDecision).ServeHTTP,
},
arbor.Route{
"FinalizeDecisionBatch",
"POST",
"/decision/finalize/batch/",
alice.New(middleware.AuthMiddleware([]models.Role{models.AdminRole}), middleware.IdentificationMiddleware).ThenFunc(FinalizeDecision).ServeHTTP,
},
arbor.Route{
"GetDecision",
"GET",
Expand All @@ -57,10 +69,18 @@ func UpdateDecision(w http.ResponseWriter, r *http.Request) {
arbor.POST(w, config.DECISION_SERVICE+r.URL.String(), DecisionFormat, "", r)
}

func UpdateDecisionBatch(w http.ResponseWriter, r *http.Request) {
arbor.POST(w, config.DECISION_SERVICE+r.URL.String(), DecisionFormat, "", r)
}

func GetFilteredDecisions(w http.ResponseWriter, r *http.Request) {
arbor.GET(w, config.DECISION_SERVICE+r.URL.String(), DecisionFormat, "", r)
}

func FinalizeDecision(w http.ResponseWriter, r *http.Request) {
arbor.POST(w, config.DECISION_SERVICE+r.URL.String(), DecisionFormat, "", r)
}

func FinalizeDecisionBatch(w http.ResponseWriter, r *http.Request) {
arbor.POST(w, config.DECISION_SERVICE+r.URL.String(), DecisionFormat, "", r)
}
Loading