Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce /stats.json #1147

Merged
merged 2 commits into from
Jul 26, 2023
Merged
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
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
29 changes: 28 additions & 1 deletion app/controllers/api_particulier/stats_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
class APIParticulier::StatsController < APIParticulierController
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 de pièces justificatives transmises sur les 2 derniers mois',
url: 'https://metabase.entreprise.api.gouv.fr/public/question/e6d80db2-e947-4916-a487-4e040fecc511.json',
type: 'application/json'
},
{
name: 'Nombre de quotients familiaux transmis sur les 2 derniers mois',
url: 'https://metabase.entreprise.api.gouv.fr/public/question/8d977c80-a675-48ea-9d73-294290f6665a.json',
type: 'application/json'
},
{
name: 'Nombre de cartes étudiants transmises sur les 2 derniers mois',
url: 'https://metabase.entreprise.api.gouv.fr/public/question/a234b04f-26de-4607-b81b-fb7c5ff79b58.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
10 changes: 10 additions & 0 deletions spec/controllers/api_particulier/stats_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
RSpec.describe APIParticulier::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