Calculate availability of Asset objects

Hello, hope someone will be able to help.
We have the following:

  • A schema in assets with a set of machines
  • A JSM project that logs issues with those machines

Now we need to calculate availability of those machines in a certain period.
The way the availability is calculated is as follows:

  1. Get each active machine total availability in the period
  2. Get each machine total downtime in the period
  3. Calculate availability by substracting 1 - 2

My first blocker is that I can get the availability in the assets cube and I can get the downtime in the Jira cube, but I am not able to integrate both for the final calculation.

My second problem is a more detailed one and it is related to the way the downtime needs to be calculated, for calculating the downtime we need to

  1. Get the time difference between 2 date fields
  2. On weekdays it needs to be from 6 am to 11 pm
  3. On weekends it needs to be from 8 am to 10 pm
  4. On public holidays it needs to be from 8 am to 10 pm
    I am able to get weekdays and weekends but I am struggling on defininf and calculating on public holidays.

Hopefully I made myself clear, I know they are 2 different issues maybe I should separate the questions.

Thanks in advance for the help.

Rodrigo