Skip to content

Commit

Permalink
API Entreprise: introduce /stats.json
Browse files Browse the repository at this point in the history
  • Loading branch information
skelz0r committed Jul 26, 2023
1 parent 1095074 commit 002b457
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
29 changes: 28 additions & 1 deletion app/controllers/api_entreprise/stats_controller.rb
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
10 changes: 10 additions & 0 deletions spec/controllers/api_entreprise/stats_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
RSpec.describe APIEntreprise::StatsController 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

0 comments on commit 002b457

Please sign in to comment.