## API response structure proposal
Currently, the goal organization endpoint only provides goals in a single array. The FE does the data transformation to separate goals based on `start_date` and `target_date`.
### Proposal
The backend api for organization should provide a new structure that transforms the data and separate them accordingly. The structure will have two keys:
- The goals for the selected cycle: this will contain all the goals that fall into the selected cycle, even if it's shorter than the selected cycle (`goal_start_date ≥ cycle_start && goal_target_date ≤ cycle_end`)
- Long term goals: Contains the rest of the goals that is beyond the current cycle
### Request Params
Example API URL
`GET /v1/goals/overview?for=organization&cycleId=1`
**URL Params**
`for=organization` - the type of overview response
`cycleId=1` - Id of the selected cycle.
#### Alternative API URL (see 'Potential issues' further down)
`GET /v1/goals/overview/organization?cycleId=1`
### Proposal
```
{
"cycleGoals": [
...goals
],
"longTermGoals": [
...goals
]
}
```
### Potential issues
`/v1/goals/overview?for=organization` endpoint is being used in
- app/containers/GoalPage/sagas.js
- app/containers/GoalsOverviewPage/sagas.js
Maybe just create a new endpoint (`/v1/goals/overview?for=organization`) here? Then mark as deprecated and refactor other instances later.
```
{
confidenceLevel: 6,
draft: false,
id: 18,
keyResults: (3) [{…}, {…}, {…}],
kind: "team",
lastStatusUpdateAt: "2020-09-25T12:48:07Z",
owner: {
avatarUrlLarge: "http://localhost:3000/system/users-avatars-19-large.jpg",
avatarUrlMedium: "http://localhost:3000/system/users-avatars-19-medium.jpg",
coach: false,
deactivated: false,
deleted: false,
…
},
permissions: {
changeOwner: true,
destroy: true,
manage: true,
showProgress: true,
updateProgress: true,
…
},
progress: 0.35,
progressCalculation: "key_results",
role: "stakeholder",
secret: true
startDate: "2020-07-01",
targetDate: "2020-09-30",
team: {
id: 2,
name: "Portfolio",
archived: false
}
title: "Users and brands alike love the way how we present portfolios as a lifestyle"
}
```