Skip to content

Commit

Permalink
Merge pull request #557 from dadosjusbr/retornando-descontos
Browse files Browse the repository at this point in the history
retornando descontos
  • Loading branch information
joellensilva committed Jun 6, 2023
2 parents 238e5cb + bc10781 commit 6bb7bef
Show file tree
Hide file tree
Showing 10 changed files with 143 additions and 11 deletions.
33 changes: 30 additions & 3 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ const docTemplate = `{
}
}
}
},
},
"/v2/dados/{orgao}/{ano}": {
"get": {
"description": "Busca os dados mensais de um órgão por ano",
Expand Down Expand Up @@ -812,7 +812,7 @@ const docTemplate = `{
},
"/v2/indice/{param}/{valor}/{ano}/{mes}": {
"get": {
"description": "Busca as informações de índices de um grupo ou órgão específico para o ano informado.",
"description": "Busca as informações de índices de um grupo ou órgão específico para o ano e mês informados.",
"produces": [
"application/json"
],
Expand Down Expand Up @@ -1097,7 +1097,7 @@ const docTemplate = `{
}
}
}
},
},
"papi.backup": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -1250,6 +1250,9 @@ const docTemplate = `{
},
"remuneracao_base": {
"$ref": "#/definitions/papi.dataSummary"
},
"descontos": {
"$ref": "#/definitions/papi.dataSummary"
}
}
},
Expand Down Expand Up @@ -1440,6 +1443,15 @@ const docTemplate = `{
},
"remuneracao_base_por_membro": {
"type": "number"
},
"descontos": {
"type": "number"
},
"descontos_por_mes": {
"type": "number"
},
"descontos_por_membro": {
"type": "number"
}
}
},
Expand Down Expand Up @@ -1507,6 +1519,9 @@ const docTemplate = `{
},
"remuneracao_base": {
"type": "number"
},
"descontos": {
"type": "number"
}
}
},
Expand Down Expand Up @@ -1650,6 +1665,9 @@ const docTemplate = `{
"max_remuneracao_base": {
"type": "number"
},
"max_descontos": {
"type": "number"
},
"orgao": {
"type": "string"
},
Expand All @@ -1659,6 +1677,9 @@ const docTemplate = `{
"remuneracao_base": {
"type": "number"
},
"descontos": {
"type": "number"
},
"tem_anterior": {
"type": "boolean"
},
Expand Down Expand Up @@ -1717,6 +1738,12 @@ const docTemplate = `{
"remuneracao_base_por_membro": {
"type": "number"
},
"descontos": {
"type": "number"
},
"descontos_por_membro": {
"type": "number"
},
"timestamp": {
"$ref": "#/definitions/uiapi.timestamp"
},
Expand Down
29 changes: 28 additions & 1 deletion docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1240,6 +1240,9 @@
},
"remuneracao_base": {
"$ref": "#/definitions/papi.dataSummary"
},
"descontos": {
"$ref": "#/definitions/papi.dataSummary"
}
}
},
Expand Down Expand Up @@ -1285,7 +1288,7 @@
"type": "integer"
},
"indice_transparencia": {
"$ref": "#/definitions/papi.dataSummary"
"$ref": "#/definitions/papi.score"
},
"metadados": {
"$ref": "#/definitions/papi.metadata"
Expand Down Expand Up @@ -1430,6 +1433,15 @@
},
"remuneracao_base_por_membro": {
"type": "number"
},
"descontos": {
"type": "number"
},
"descontos_por_mes": {
"type": "number"
},
"descontos_por_membro": {
"type": "number"
}
}
},
Expand Down Expand Up @@ -1497,6 +1509,9 @@
},
"remuneracao_base": {
"type": "number"
},
"descontos": {
"type": "number"
}
}
},
Expand Down Expand Up @@ -1640,6 +1655,9 @@
"max_remuneracao_base": {
"type": "number"
},
"max_descontos": {
"type": "number"
},
"orgao": {
"type": "string"
},
Expand All @@ -1649,6 +1667,9 @@
"remuneracao_base": {
"type": "number"
},
"descontos": {
"type": "number"
},
"tem_anterior": {
"type": "boolean"
},
Expand Down Expand Up @@ -1707,6 +1728,12 @@
"remuneracao_base_por_membro": {
"type": "number"
},
"descontos": {
"type": "number"
},
"descontos_por_membro": {
"type": "number"
},
"timestamp": {
"$ref": "#/definitions/uiapi.timestamp"
},
Expand Down
18 changes: 18 additions & 0 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ definitions:
type: integer
remuneracao_base:
$ref: "#/definitions/papi.dataSummary"
descontos:
$ref: "#/definitions/papi.dataSummary"
type: object
papi.summaryzedMI:
properties:
Expand Down Expand Up @@ -306,6 +308,12 @@ definitions:
type: number
remuneracao_base_por_membro:
type: number
descontos:
type: number
descontos_por_mes:
type: number
descontos_por_membro:
type: number
type: object
uiapi.backup:
properties:
Expand Down Expand Up @@ -353,6 +361,8 @@ definitions:
type: number
remuneracao_base:
type: number
descontos:
type: number
type: object
uiapi.procError:
properties:
Expand Down Expand Up @@ -446,12 +456,16 @@ definitions:
type: number
max_remuneracao_base:
type: number
max_descontos:
type: number
orgao:
type: string
outras_remuneracoes:
type: number
remuneracao_base:
type: number
descontos:
type: number
tem_anterior:
type: boolean
tem_proximo:
Expand Down Expand Up @@ -490,6 +504,10 @@ definitions:
type: number
remuneracao_base_por_membro:
type: number
descontos:
type: number
descontos_por_membro:
type: number
timestamp:
$ref: "#/definitions/uiapi.timestamp"
total_membros:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.18

require (
github.com/dadosjusbr/proto v0.0.0-20221212025627-91c60aa3cd12
github.com/dadosjusbr/storage v0.0.0-20230516114123-dc6ae51c4bb1
github.com/dadosjusbr/storage v0.0.0-20230606144319-60c7b5d6eb77
github.com/gocarina/gocsv v0.0.0-20220712153207-8b2118da4570
github.com/golang/mock v1.6.0
github.com/joho/godotenv v1.4.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ github.com/dadosjusbr/storage v0.0.0-20230420170502-31dc5a2caf92 h1:73BiNvlognV5
github.com/dadosjusbr/storage v0.0.0-20230420170502-31dc5a2caf92/go.mod h1:ttc45wBL5bjz5uU24mgNNPV9ZHaJ3SmoRwVOmyVRZyY=
github.com/dadosjusbr/storage v0.0.0-20230516114123-dc6ae51c4bb1 h1:cW0gM/0LR2Zth/lvO4plo0YWCZb4oZ686tIXgLcI0QE=
github.com/dadosjusbr/storage v0.0.0-20230516114123-dc6ae51c4bb1/go.mod h1:ttc45wBL5bjz5uU24mgNNPV9ZHaJ3SmoRwVOmyVRZyY=
github.com/dadosjusbr/storage v0.0.0-20230606144319-60c7b5d6eb77 h1:/nTEm9H8P5IUzDTuQkwFod/BoruZIObWr7sUO07Kov4=
github.com/dadosjusbr/storage v0.0.0-20230606144319-60c7b5d6eb77/go.mod h1:ttc45wBL5bjz5uU24mgNNPV9ZHaJ3SmoRwVOmyVRZyY=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down
24 changes: 24 additions & 0 deletions papi/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,12 @@ func (h handler) GetMonthlyInfo(c echo.Context) error {
Average: mi.Summary.OtherRemunerations.Average,
Total: mi.Summary.OtherRemunerations.Total,
},
Discounts: dataSummary{
Max: mi.Summary.Discounts.Max,
Min: mi.Summary.Discounts.Min,
Average: mi.Summary.Discounts.Average,
Total: mi.Summary.Discounts.Total,
},
},
},
Metadata: &metadata{
Expand Down Expand Up @@ -306,6 +312,12 @@ func (h handler) V2GetMonthlyInfo(c echo.Context) error {
Average: monthlyInfo.Summary.OtherRemunerations.Average,
Total: monthlyInfo.Summary.OtherRemunerations.Total,
},
Discounts: dataSummary{
Max: monthlyInfo.Summary.Discounts.Max,
Min: monthlyInfo.Summary.Discounts.Min,
Average: monthlyInfo.Summary.Discounts.Average,
Total: monthlyInfo.Summary.Discounts.Total,
},
},
},
Metadata: &metadata{
Expand Down Expand Up @@ -414,6 +426,12 @@ func (h handler) GetMonthlyInfosByYear(c echo.Context) error {
Average: mi.Summary.OtherRemunerations.Average,
Total: mi.Summary.OtherRemunerations.Total,
},
Discounts: dataSummary{
Max: mi.Summary.Discounts.Max,
Min: mi.Summary.Discounts.Min,
Average: mi.Summary.Discounts.Average,
Total: mi.Summary.Discounts.Total,
},
},
},
Metadata: &metadata{
Expand Down Expand Up @@ -667,6 +685,12 @@ func (h handler) V2GetAllAgencyInformation(c echo.Context) error {
Average: c.Summary.OtherRemunerations.Average,
Total: c.Summary.OtherRemunerations.Total,
},
Discounts: dataSummary{
Max: c.Summary.Discounts.Max,
Min: c.Summary.Discounts.Min,
Average: c.Summary.Discounts.Average,
Total: c.Summary.Discounts.Total,
},
},
},
Metadata: &metadata{
Expand Down
1 change: 1 addition & 0 deletions papi/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type summary struct {
Count int `json:"quantidade,omitempty"`
BaseRemuneration dataSummary `json:"remuneracao_base,omitempty"`
OtherRemunerations dataSummary `json:"outras_remuneracoes,omitempty"`
Discounts dataSummary `json:"descontos,omitempty"`
}

type summaries struct {
Expand Down
16 changes: 12 additions & 4 deletions uiapi/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ func (h handler) V2GetSummaryOfAgency(c echo.Context) error {
MaxBase: agencyMonthlyInfo.Summary.BaseRemuneration.Max,
OtherRemunerations: agencyMonthlyInfo.Summary.OtherRemunerations.Total,
MaxOther: agencyMonthlyInfo.Summary.OtherRemunerations.Max,
Discounts: agencyMonthlyInfo.Summary.Discounts.Total,
MaxDiscounts: agencyMonthlyInfo.Summary.Discounts.Max,
TotalRemuneration: agencyMonthlyInfo.Summary.BaseRemuneration.Total +
agencyMonthlyInfo.Summary.OtherRemunerations.Total,
TotalMembers: agencyMonthlyInfo.Summary.Count,
Expand Down Expand Up @@ -318,13 +320,13 @@ func (h handler) V2GetTotalsOfAgencyYear(c echo.Context) error {
strAgency.URL = fmt.Sprintf("%s/v2/orgao/%s", host, strAgency.ID)
for _, agencyMonthlyInfo := range agenciesMonthlyInfo[aID] {
if agencyMonthlyInfo.Summary != nil && agencyMonthlyInfo.Summary.BaseRemuneration.Total+agencyMonthlyInfo.Summary.OtherRemunerations.Total > 0 {
baseRemPerCapita := agencyMonthlyInfo.Summary.BaseRemuneration.Total / float64(agencyMonthlyInfo.Summary.Count)
otherRemPerCapita := agencyMonthlyInfo.Summary.OtherRemunerations.Total / float64(agencyMonthlyInfo.Summary.Count)
monthTotals := v2MonthTotals{Month: agencyMonthlyInfo.Month,
BaseRemuneration: agencyMonthlyInfo.Summary.BaseRemuneration.Total,
OtherRemunerations: agencyMonthlyInfo.Summary.OtherRemunerations.Total,
BaseRemunerationPerCapita: baseRemPerCapita,
OtherRemunerationsPerCapita: otherRemPerCapita,
Discounts: agencyMonthlyInfo.Summary.Discounts.Total,
BaseRemunerationPerCapita: agencyMonthlyInfo.Summary.BaseRemuneration.Average,
OtherRemunerationsPerCapita: agencyMonthlyInfo.Summary.OtherRemunerations.Average,
DiscountsPerCapita: agencyMonthlyInfo.Summary.Discounts.Average,
CrawlingTimestamp: timestamp{
Seconds: agencyMonthlyInfo.CrawlingTimestamp.GetSeconds(),
Nanos: agencyMonthlyInfo.CrawlingTimestamp.GetNanos(),
Expand Down Expand Up @@ -580,6 +582,7 @@ func (h handler) V2GetGeneralRemunerationFromYear(c echo.Context) error {
Members: d.Count,
BaseRemuneration: d.BaseRemuneration,
OtherRemunerations: d.OtherRemunerations,
Discounts: d.Discounts,
})
}
return c.JSON(http.StatusOK, annualRemu)
Expand Down Expand Up @@ -787,6 +790,8 @@ func (h handler) GetAnnualSummary(c echo.Context) error {
baseRemPerCapita := s.BaseRemuneration / float64(s.TotalCount)
otherRemPerMonth := s.OtherRemunerations / float64(s.NumMonthsWithData)
otherRemPerCapita := s.OtherRemunerations / float64(s.TotalCount)
discountsRemPerMonth := s.Discounts / float64(s.NumMonthsWithData)
discountsRemPerCapita := s.Discounts / float64(s.TotalCount)
annualData = append(annualData, annualSummaryData{
Year: s.Year,
AverageMemberCount: s.AverageCount,
Expand All @@ -796,6 +801,9 @@ func (h handler) GetAnnualSummary(c echo.Context) error {
OtherRemunerations: s.OtherRemunerations,
OtherRemunerationsPerMonth: otherRemPerMonth,
OtherRemunerationsPerCapita: otherRemPerCapita,
Discounts: s.Discounts,
DiscountsPerMonth: discountsRemPerMonth,
DiscountsPerCapita: discountsRemPerCapita,
NumMonthsWithData: s.NumMonthsWithData,
Package: &backup{
URL: s.Package.URL,
Expand Down
8 changes: 8 additions & 0 deletions uiapi/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ type v2AgencySummary struct {
MaxBase float64 `json:"max_remuneracao_base"`
OtherRemunerations float64 `json:"outras_remuneracoes"`
MaxOther float64 `json:"max_outras_remuneracoes"`
Discounts float64 `json:"descontos"`
MaxDiscounts float64 `json:"max_descontos"`
CrawlingTime timestamp `json:"timestamp"`
TotalMembers int `json:"total_membros"`
TotalRemuneration float64 `json:"total_remuneracao"`
Expand Down Expand Up @@ -155,6 +157,8 @@ type v2MonthTotals struct {
BaseRemunerationPerCapita float64 `json:"remuneracao_base_por_membro"`
OtherRemunerations float64 `json:"outras_remuneracoes"`
OtherRemunerationsPerCapita float64 `json:"outras_remuneracoes_por_membro"`
Discounts float64 `json:"descontos"`
DiscountsPerCapita float64 `json:"descontos_por_membro"`
CrawlingTimestamp timestamp `json:"timestamp"`
}

Expand Down Expand Up @@ -250,6 +254,9 @@ type annualSummaryData struct {
OtherRemunerations float64 `json:"outras_remuneracoes"`
OtherRemunerationsPerMonth float64 `json:"outras_remuneracoes_por_mes"`
OtherRemunerationsPerCapita float64 `json:"outras_remuneracoes_por_membro"`
Discounts float64 `json:"descontos"`
DiscountsPerMonth float64 `json:"descontos_por_mes"`
DiscountsPerCapita float64 `json:"descontos_por_membro"`
NumMonthsWithData int `json:"meses_com_dados"`
Package *backup `json:"package,omitempty"`
}
Expand All @@ -259,4 +266,5 @@ type mensalRemuneration struct {
Members int `json:"num_membros,omitempty"`
BaseRemuneration float64 `json:"remuneracao_base"`
OtherRemunerations float64 `json:"outras_remuneracoes"`
Discounts float64 `json:"descontos"`
}
Loading

0 comments on commit 6bb7bef

Please sign in to comment.