appuio / appuio-cloud-reporting

Reporting for APPUiO Cloud
BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

Add support for sub queries #55

Closed glrf closed 2 years ago

glrf commented 2 years ago

Summary

This PR introduces sub queries

For data ingestion, sub queries are handled the same as normal queries. The only difference is that sub queries will also be executed when running report for the main query.

Invoice generation will group reports for sub-facts (i.e. facts generated by a sub-query) as sub-items for query line items. That means if we have a query foo with a sub-query sub-foo and sub-foo2 and a query bar. When generating an invoice we will get the line items

items:
- description: foo
  quantity: 4
  ....
  total: 1337
  subItems:
  - description: sub-foo
    quantity: 1
    ....
  - description: sub-foo2
    quantity: 3
    ....
- description: bar
  quantity: 7
  ....
  total: 42

Sub items will not show up in the total of the main item.

Checklist

glrf commented 2 years ago

I fixed two things:

As discussed I will refactor the tests in a separate PR