-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
API Entreprise: introduce /stats.json
- Loading branch information
Showing
2 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,32 @@ | ||
class APIEntreprise::StatsController < APIEntrepriseController | ||
def index | ||
render 'index' | ||
respond_to do |format| | ||
format.html | ||
format.json do | ||
render json: data_collection | ||
end | ||
end | ||
end | ||
|
||
private | ||
|
||
def data_collection | ||
[ | ||
{ | ||
name: 'Nombre d\'appels pour une unité légale sur les 2 derniers mois', | ||
url: 'https://metabase.entreprise.api.gouv.fr/public/question/021a0118-2071-416c-8527-e76e350b1d03.json', | ||
type: 'application/json' | ||
}, | ||
{ | ||
name: 'Nombre d\'appels totaux sur les 2 derniers mois', | ||
url: 'https://metabase.entreprise.api.gouv.fr/public/question/b3923a04-55d3-4c79-a035-201a6d0e2d13.json', | ||
type: 'application/json' | ||
}, | ||
{ | ||
name: 'Nombre d\'appels uniques sur les 2 derniers mois', | ||
url: 'https://metabase.entreprise.api.gouv.fr/public/question/f62b61aa-227e-4f0e-b9f0-605913771cde.json', | ||
type: 'application/json' | ||
} | ||
] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
RSpec.describe APIEntreprise::StatsController, type: :controller do | ||
describe 'GET #index as json' do | ||
subject(:get_index) { get :index, params: { format: :json } } | ||
|
||
before { get_index } | ||
|
||
it { is_expected.to have_http_status(:success) } | ||
it { expect(JSON.parse(response.body)).to be_an(Array) } | ||
end | ||
end |