fix(engine): calculate history duration with Java

- go back to calculating duration in Java. Costs: additional SELECT

related to #CAM-1346