sdec-brasil / invoice-explorer

API + Interface Pública para Resgate de Informações do SDEC
MIT License
1 stars 0 forks source link

Amount of Invoices in a Single City #8

Closed tloriato closed 5 years ago

tloriato commented 5 years ago

Given the city (prefeitura) X, we would like to have a breakdown of those values:

It's the amount of invoices issued in that city, basically a count from all invoices where competencia = x.

Screen Shot 2019-07-10 at 10 51 08 PM

Related to sdec-brasil/old-dashboard#60

dbeyda commented 5 years ago

By the graph presented, I'm assuming we also need to filter by month/year and then aggregate those invoices counts by day, right? To return a list of [(day, count)].

tloriato commented 5 years ago

Yes

dbeyda commented 5 years ago

Request:

GET /v1/cities/1100015/daily-issuing?month=7&year=2019

Response:

{
    "city": {
        "codigoMunicipio": "1100015",
        "cnpj": "18511471000120",
        "municipio.codigoIbge": "1100015",
        "municipio.nome": "Alta Floresta D'Oeste",
        "municipio.uf": "RO",
        "municipio.nomeRegiao": "Leste Rondoniense",
        "municipio.estado.sigla": "RO",
        "municipio.estado.nome": "Rondônia",
        "municipio.regiao.nomeRegiao": "Leste Rondoniense",
        "municipio.regiao.uf": "RO"
    },
    "dailyIssuing": [
        {
            "dataIncidencia": "2019-05-21",
            "emitedInvoicesCount": 3
        },
        {
            "dataIncidencia": "2019-05-23",
            "emitedInvoicesCount": 4
        },
        {
            "dataIncidencia": "2019-05-25",
            "emitedInvoicesCount": 5
        },
        {
            "dataIncidencia": "2019-05-26",
            "emitedInvoicesCount": 5
        },
        {
            "dataIncidencia": "2019-05-27",
            "emitedInvoicesCount": 2
        },
        {
            "dataIncidencia": "2019-05-28",
            "emitedInvoicesCount": 4
        },
        {
            "dataIncidencia": "2019-05-29",
            "emitedInvoicesCount": 1
        },
        {
            "dataIncidencia": "2019-05-31",
            "emitedInvoicesCount": 6
        }
    ]
}

Note that days with zero invoices are no shown in the query. I suggest that this should be treated in the front-end, since seems like an easy fix. In the backend, we are currently just using Database functions and returning the result. Treating this in the backend would add some overhead to the response time.

tloriato commented 5 years ago

off-topic: we need to fix that city endpoint and property names after, it's pretty ugly lol

dbeyda commented 5 years ago

@tloriato can we close this?

tloriato commented 5 years ago

Sure, daveboy

tloriato commented 5 years ago

Sure, daveboy