Code Monkey home page Code Monkey logo

reports's Introduction

codecov Go Report Card

Пример API формирования отчетов на POSTGRES + GO

Запуск демо версии локально c docker-compose

docker-compose up --build

На localhost:8080 будет доступно приложение

Разработка

Скомпилировать бинарник

make build 

Для запуска тестов понадобится утилита go-acc github.com/ory/go-acc

go get github.com/ory/go-acc

Форматирование кода всего проекта:

make fmt

Запуск линтеров:

make lint

Запуск тестов:

make test

Переменные среды

PG_PORT=5432
PG_HOST=pghost
PG_USER=postgres
PG_PASSWORD=123456
PG_DBNAME=postgres
APP_HOST=
APP_PORT=80

API

Выбор библиотеки для формирования excel обоснован бенчмарками тут

Report1

JSON

Endpoint: GET /r1/json

Response:

{
  "categories": [
    {
      "name": "Пиццы",
      "products": [
        {
          "name": "4сыра",
          "count": 3,
          "cost_sum": "451.38",
          "sell_sum": "1350.80"
        },
        {
          "name": "Мясное Плато",
          "count": 6,
          "cost_sum": "901.03",
          "sell_sum": "2850.59"
        }
      ],
      "count": 9,
      "cost_sum": "1352.41",
      "sell_sum": "4201.38"
    },
    {
      "name": "Супы",
      "products": [
        {
          "name": "Борщ",
          "count": 3,
          "cost_sum": "90.99",
          "sell_sum": "300.29"
        },
        {
          "name": "Харчо",
          "count": 3,
          "cost_sum": "60.51",
          "sell_sum": "200.59"
        }
      ],
      "count": 6,
      "cost_sum": "151.50",
      "sell_sum": "500.88"
    }
  ],
  "count": 15,
  "cost_sum": "1503.91",
  "sell_sum": "4702.26"
}

XLSX

Endpoint: GET /r1/xlsx

Report2

JSON

Endpoint: GET /r2/json

Response:

{
  "categories": [
    {
      "name": "Пиццы",
      "products": [
        {
          "name": "4сыра",
          "count": 3,
          "cost_sum": "451.38",
          "sell_sum": "1350.80"
        },
        {
          "name": "Мясное Плато",
          "count": 6,
          "cost_sum": "901.03",
          "sell_sum": "2850.59"
        }
      ],
      "count": 9,
      "cost_sum": "1352.41",
      "sell_sum": "4201.38"
    },
    {
      "name": "Супы",
      "products": [
        {
          "name": "Борщ",
          "count": 3,
          "cost_sum": "90.99",
          "sell_sum": "300.29"
        },
        {
          "name": "Харчо",
          "count": 3,
          "cost_sum": "60.51",
          "sell_sum": "200.59"
        }
      ],
      "count": 6,
      "cost_sum": "151.50",
      "sell_sum": "500.88"
    }
  ],
  "count": 15,
  "cost_sum": "1503.91",
  "sell_sum": "4702.26"
}

XLSX

Endpoint: GET /r2/xlsx

reports's People

Contributors

delgus avatar

Watchers

 avatar  avatar

reports's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.