[FEAT][API] Create a privacy metrics job
- Dominant language
- Go
- Stars
- 6
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
## Description
Create a privacy metrics job.
## Request
### Method
POST
### URL
/jobs/metrics/privacy
### Request Parameters
| Parameter | Description | Required | Example |
|---|---|---|---|
| id | UUID. The id of the new job. | Yes | bcf13e3d-e3b7-4d6d-8059-e75a8b2d3e60 |
### Request Body
```json
{
"kind": "privacy_metrics",
"parameters": {
"table": "table_name",
"columns": ["column_name"]
}
}
```
## Result
### Result parameters
N/A
### Result Body
```json
{
"id": "bcf13e3d-e3b7-4d6d-8059-e75a8b2d3e60",
"kind": "privacy_metrics",
"created_at": "2023-03-08T12:34:56.789Z",
"status": "enqueued",
"error_message": null,
"traceback": null,
"result": null,
"parameters": {
"table": "table_name",
"columns": ["column_name"]
},
"current_progress": null
}
```
## Example Curl Request
### Request
```
curl -X POST \
http://localhost:8080/jobs/metrics/privacy \
-H 'Content-Type: application/json' \
-d '{
"id": "bcf13e3d-e3b7-4d6d-8059-e75a8b2d3e60",
"kind": "privacy_metrics",
"parameters": {
"table": "table_name",
"columns": ["column_name"]
}
}'
```
### Curl Response
```json
{
"id": "bcf13e3d-e3b7-4d6d-8059-e75a8b2d3e60",
"kind": "privacy_metrics",
"created_at": "2023-03-08T12:34:56.789Z",
"status": "enqueued",
"error_message": null,
"traceback": null,
"result": null,
"parameters": {
"table": "table_name",
"columns": ["column_name"]
},
"current_progress": null
}
```
## Go server
### Struct
```go
type PrivacyMetricsJobCreateRequest struct {
ID string `json:"id"`
Kind JobKind `json:"kind"`
Parameters PrivacyMetricsParameters `json:"parameters"`
}
```
### Handler
```go
func (s *Server) CreatePrivacyMetricsJob(w http.ResponseWriter, r *http.Request) {
var req PrivacyMetricsJobCreateRequest
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
http.Error(w, "failed to parse request body", http.StatusBadRequest)
return
}
resp, err := s.db.CreatePrivacyMetricsJob(r.Context(), req)
if err != nil {
http.Error(w, "failed to create job", http.StatusInternalServerError)
return
}
if err := json.NewEncoder(w).Encode(resp); err != nil {
http.Error(w, "failed to encode response", http.StatusInternalServerError)
return
}
}
```
## Links
- [Jobs.create_privacy_metrics_job](https://github.com/octopize/avatar-python/blob/0.6.2/avatars/api.py#L600)
- [PrivacyMetricsJobCreate](https://github.com/octopize/avatar-python/blob/0.6.2/avatars/api.py#L600)
- [PrivacyMetricsJob](https://github.com/octopize/avatar-python/blob/0.6.2/avatars/api.py#L600)
## Automated Issue Details
Dear visitor,
This issue has been automatically generated from the Octopize project [avatar-python](https://github.com/octopize/avatar-python/) to make SIGO compatible. Please vote with a thumbs up or thumbs down to assess the quality of the automatic generation.
Best regards,
The SIGO Team
Contributor guide
Research direction
Locate the Go server's PrivacyMetricsJobCreateRequest and CreatePrivacyMetricsJob entry points, then compare them with the linked avatar-python job definitions. Verify how the POST /jobs/metrics/privacy request is decoded and passed to the database, and confirm that a successful request returns the documented enqueued job response with the supplied parameters.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100