Skip to content

Commit c403c47

Browse files
committed
feat: add 'inconsistent' field to summaryzedMI, v2MonthTotals, and annualSummaryData
1 parent e969098 commit c403c47

File tree

7 files changed

+166
-163
lines changed

7 files changed

+166
-163
lines changed

go.mod

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.18
44

55
require (
66
github.com/dadosjusbr/proto v0.0.0-20221212025627-91c60aa3cd12
7-
github.com/dadosjusbr/storage v0.0.0-20240923172949-d3b675a3e292
7+
// github.com/dadosjusbr/storage v0.0.0-20240923172949-d3b675a3e292
88
github.com/gocarina/gocsv v0.0.0-20220712153207-8b2118da4570
99
github.com/golang/mock v1.6.0
1010
github.com/joho/godotenv v1.4.0
@@ -32,6 +32,8 @@ require (
3232
github.com/go-sql-driver/mysql v1.7.0 // indirect
3333
)
3434

35+
require github.com/dadosjusbr/storage v0.0.0-00010101000000-000000000000
36+
3537
require (
3638
github.com/davecgh/go-spew v1.1.1 // indirect
3739
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
@@ -70,3 +72,5 @@ require (
7072
google.golang.org/genproto v0.0.0-20230127162408-596548ed4efa // indirect
7173
google.golang.org/grpc v1.53.0 // indirect
7274
)
75+
76+
replace github.com/dadosjusbr/storage => ../storage

go.sum

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,9 @@ github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7
3131
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
3232
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
3333
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
34-
github.com/dadosjusbr/datapackage v0.0.0-20230904162108-6e2264aafb68/go.mod h1:o1FghJC46mR+lgHcQWVve/q84/SAd0WVdYMcgq88BBU=
3534
github.com/dadosjusbr/datapackage v0.0.0-20240320203926-5f369dadd3a5/go.mod h1:xDZc4jX8VDOP7SFo793x0Q8gjUjuMSOmNEUG/wqLKAw=
3635
github.com/dadosjusbr/proto v0.0.0-20221212025627-91c60aa3cd12 h1:ufl8nbCEo6g2VHUbedGy0gYk9Sgrynf9rcnzuSw4TEg=
3736
github.com/dadosjusbr/proto v0.0.0-20221212025627-91c60aa3cd12/go.mod h1:gPA7VxjEmyez/xtln4qBj+tM1NO0/zcw3ryjxTRNSco=
38-
github.com/dadosjusbr/storage v0.0.0-20240315221019-5da10c81ab80 h1:mo6k/MAl6aF662JFUYHxqCNvRkX8OXZN0DmQKJe55D4=
39-
github.com/dadosjusbr/storage v0.0.0-20240315221019-5da10c81ab80/go.mod h1:PszGy6CDoG3kNLjIsCmwD3MAWED7xL7U/OWj7ajsiHc=
40-
github.com/dadosjusbr/storage v0.0.0-20240514131514-43ac5da3ae8a h1:1LyzfsNzKgLjC4/cyQr+N724a4dcRCHB5yIauAnhhcI=
41-
github.com/dadosjusbr/storage v0.0.0-20240514131514-43ac5da3ae8a/go.mod h1:rIM/dbZMdrMfVnZgNgRNRRtsxfhSMH8S8X7MZEeKkrQ=
42-
github.com/dadosjusbr/storage v0.0.0-20240913213102-72765cc03b4e h1:RNcbmof3iPyJQNWbEPkNyKKffmQ8jkZa8QH/vZ5eJP0=
43-
github.com/dadosjusbr/storage v0.0.0-20240913213102-72765cc03b4e/go.mod h1:rIM/dbZMdrMfVnZgNgRNRRtsxfhSMH8S8X7MZEeKkrQ=
44-
github.com/dadosjusbr/storage v0.0.0-20240923172949-d3b675a3e292 h1:cgrdaqWjNN9enNcWPaPtqWFbxo1bLWz9C/Lxhke4WM4=
45-
github.com/dadosjusbr/storage v0.0.0-20240923172949-d3b675a3e292/go.mod h1:rIM/dbZMdrMfVnZgNgRNRRtsxfhSMH8S8X7MZEeKkrQ=
4637
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4738
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
4839
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=

papi/handlers.go

Lines changed: 62 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ func (h handler) V1GetAgencyById(c echo.Context) error {
3939
return c.JSON(http.StatusOK, agency)
4040
}
4141

42-
// @ID GetAgencyById
43-
// @Tags public_api
44-
// @Description Busca um órgão específico utilizando seu ID.
45-
// @Produce json
46-
// @Param orgao path string true "ID do órgão. Exemplos: tjal, tjba, mppb."
47-
// @Success 200 {object} agency "Requisição bem sucedida."
48-
// @Failure 404 {string} string "Órgão não encontrado."
49-
// @Router /v2/orgao/{orgao} [get]
42+
// @ID GetAgencyById
43+
// @Tags public_api
44+
// @Description Busca um órgão específico utilizando seu ID.
45+
// @Produce json
46+
// @Param orgao path string true "ID do órgão. Exemplos: tjal, tjba, mppb."
47+
// @Success 200 {object} agency "Requisição bem sucedida."
48+
// @Failure 404 {string} string "Órgão não encontrado."
49+
// @Router /v2/orgao/{orgao} [get]
5050
func (h handler) V2GetAgencyById(c echo.Context) error {
5151
agencyName := c.Param("orgao")
5252
strAgency, err := h.client.Db.GetAgency(agencyName)
@@ -92,13 +92,13 @@ func (h handler) V1GetAllAgencies(c echo.Context) error {
9292
return c.JSON(http.StatusOK, agencies)
9393
}
9494

95-
// @ID GetAllAgencies
96-
// @Tags public_api
97-
// @Description Busca todos os órgãos disponíveis.
98-
// @Produce json
99-
// @Success 200 {object} []agency "Requisição bem sucedida."
100-
// @Failure 500 {string} string "Erro interno do servidor."
101-
// @Router /v2/orgaos [get]
95+
// @ID GetAllAgencies
96+
// @Tags public_api
97+
// @Description Busca todos os órgãos disponíveis.
98+
// @Produce json
99+
// @Success 200 {object} []agency "Requisição bem sucedida."
100+
// @Failure 500 {string} string "Erro interno do servidor."
101+
// @Router /v2/orgaos [get]
102102
func (h handler) V2GetAllAgencies(c echo.Context) error {
103103
strAgencies, err := h.client.Db.GetAllAgencies()
104104
if err != nil {
@@ -264,17 +264,17 @@ func (h handler) GetMonthlyInfo(c echo.Context) error {
264264
return c.JSON(http.StatusOK, sumMI)
265265
}
266266

267-
// @ID GetMonthlyInfo
268-
// @Tags public_api
269-
// @Description Busca um dado mensal de um órgão
270-
// @Produce json
271-
// @Success 200 {object} summaryzedMI "Requisição bem sucedida"
272-
// @Failure 400 {string} string "Parâmetros inválidos"
273-
// @Failure 404 {string} string "Não existem dados para os parâmetros informados"
274-
// @Param ano path int true "Ano"
275-
// @Param orgao path string true "Órgão"
276-
// @Param mes path int true "Mês"
277-
// @Router /v2/dados/{orgao}/{ano}/{mes} [get]
267+
// @ID GetMonthlyInfo
268+
// @Tags public_api
269+
// @Description Busca um dado mensal de um órgão
270+
// @Produce json
271+
// @Success 200 {object} summaryzedMI "Requisição bem sucedida"
272+
// @Failure 400 {string} string "Parâmetros inválidos"
273+
// @Failure 404 {string} string "Não existem dados para os parâmetros informados"
274+
// @Param ano path int true "Ano"
275+
// @Param orgao path string true "Órgão"
276+
// @Param mes path int true "Mês"
277+
// @Router /v2/dados/{orgao}/{ano}/{mes} [get]
278278
func (h handler) V2GetMonthlyInfo(c echo.Context) error {
279279
year, err := strconv.Atoi(c.Param("ano"))
280280
if err != nil {
@@ -374,6 +374,7 @@ func (h handler) V2GetMonthlyInfo(c echo.Context) error {
374374
ParserVersion: monthlyInfo.ParserVersion,
375375
},
376376
ManualCollection: monthlyInfo.ManualCollection,
377+
Inconsistent: monthlyInfo.Inconsistent,
377378
}
378379
//O status 4 informa que os dados estão indisponíveis. Ao removê-los dos resultados da API, garantimos que eles sejam exibidos como se não houvesse dados.
379380
} else if monthlyInfo.ProcInfo.Status != 4 {
@@ -397,16 +398,16 @@ func (h handler) V2GetMonthlyInfo(c echo.Context) error {
397398
return c.JSON(http.StatusOK, sumMI)
398399
}
399400

400-
// @ID GetMonthlyInfosByYear
401-
// @Tags public_api
402-
// @Description Busca os dados mensais de um órgão por ano
403-
// @Produce json
404-
// @Success 200 {object} []summaryzedMI "Requisição bem sucedida"
405-
// @Failure 400 {string} string "Parâmetros inválidos"
406-
// @Failure 404 {string} string "Não existem dados para os parâmetros informados"
407-
// @Param ano path int true "Ano"
408-
// @Param orgao path string true "Órgão"
409-
// @Router /v2/dados/{orgao}/{ano} [get]
401+
// @ID GetMonthlyInfosByYear
402+
// @Tags public_api
403+
// @Description Busca os dados mensais de um órgão por ano
404+
// @Produce json
405+
// @Success 200 {object} []summaryzedMI "Requisição bem sucedida"
406+
// @Failure 400 {string} string "Parâmetros inválidos"
407+
// @Failure 404 {string} string "Não existem dados para os parâmetros informados"
408+
// @Param ano path int true "Ano"
409+
// @Param orgao path string true "Órgão"
410+
// @Router /v2/dados/{orgao}/{ano} [get]
410411
func (h handler) GetMonthlyInfosByYear(c echo.Context) error {
411412
year, err := strconv.Atoi(c.Param("ano"))
412413
if err != nil {
@@ -531,16 +532,16 @@ func (h handler) GetMonthlyInfosByYear(c echo.Context) error {
531532
return c.JSON(http.StatusOK, sumMI)
532533
}
533534

534-
// @ID GetAggregateIndexesWithParams
535-
// @Tags public_api
536-
// @Description Busca as informações de índices de um grupo ou órgão específico.
537-
// @Produce json
538-
// @Success 200 {object} []aggregateIndexes "Requisição bem sucedida."
539-
// @Failure 400 {string} string "Requisição inválida."
540-
// @Failure 500 {string} string "Erro interno do servidor."
541-
// @Param param path string true "'grupo' ou 'orgao'"
542-
// @Param valor path string true "Jurisdição ou ID do órgao"
543-
// @Router /v2/indice/{param}/{valor} [get]
535+
// @ID GetAggregateIndexesWithParams
536+
// @Tags public_api
537+
// @Description Busca as informações de índices de um grupo ou órgão específico.
538+
// @Produce json
539+
// @Success 200 {object} []aggregateIndexes "Requisição bem sucedida."
540+
// @Failure 400 {string} string "Requisição inválida."
541+
// @Failure 500 {string} string "Erro interno do servidor."
542+
// @Param param path string true "'grupo' ou 'orgao'"
543+
// @Param valor path string true "Jurisdição ou ID do órgao"
544+
// @Router /v2/indice/{param}/{valor} [get]
544545
func (h handler) V2GetAggregateIndexesWithParams(c echo.Context) error {
545546
param := c.Param("param")
546547
valor := c.Param("valor")
@@ -688,13 +689,13 @@ func (h handler) V2GetAggregateIndexesWithParams(c echo.Context) error {
688689
return c.JSON(http.StatusOK, aggregate)
689690
}
690691

691-
// @ID GetAggregateIndexes
692-
// @Tags public_api
693-
// @Description Busca as informações de índices de todos os órgãos.
694-
// @Produce json
695-
// @Success 200 {object} []aggregateIndexesByGroup "Requisição bem sucedida."
696-
// @Failure 500 {string} string "Erro interno do servidor."
697-
// @Router /v2/indice [get]
692+
// @ID GetAggregateIndexes
693+
// @Tags public_api
694+
// @Description Busca as informações de índices de todos os órgãos.
695+
// @Produce json
696+
// @Success 200 {object} []aggregateIndexesByGroup "Requisição bem sucedida."
697+
// @Failure 500 {string} string "Erro interno do servidor."
698+
// @Router /v2/indice [get]
698699
func (h handler) V2GetAggregateIndexes(c echo.Context) error {
699700
agregado := c.QueryParam("agregado")
700701
detalhe := c.QueryParam("detalhe")
@@ -798,14 +799,14 @@ func (h handler) V2GetAggregateIndexes(c echo.Context) error {
798799
return c.JSON(http.StatusOK, dados)
799800
}
800801

801-
// @ID GetAllAgencyInformation
802-
// @Tags public_api
803-
// @Description Busca todas as informações de um órgão específico.
804-
// @Produce json
805-
// @Success 200 {object} allAgencyInformation "Requisição bem sucedida."
806-
// @Failure 400 {string} string "Requisição inválida."
807-
// @Param orgao path string true "órgão"
808-
// @Router /v2/dados/{orgao} [get]
802+
// @ID GetAllAgencyInformation
803+
// @Tags public_api
804+
// @Description Busca todas as informações de um órgão específico.
805+
// @Produce json
806+
// @Success 200 {object} allAgencyInformation "Requisição bem sucedida."
807+
// @Failure 400 {string} string "Requisição inválida."
808+
// @Param orgao path string true "órgão"
809+
// @Router /v2/dados/{orgao} [get]
809810
func (h handler) V2GetAllAgencyInformation(c echo.Context) error {
810811
agency := strings.ToLower(c.Param("orgao"))
811812

papi/models.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ type summaryzedMI struct {
8282
Collect *collect `json:"dados_coleta,omitempty"`
8383
ManualCollection bool `json:"coleta_manual"`
8484
Error *miError `json:"error,omitempty"`
85+
Inconsistent bool `json:"inconsistente"`
8586
}
8687

8788
type agency struct {

0 commit comments

Comments
 (0)