Is it possible to use the D8 EntityQuery condition and sort functionality to filter/sort based on the outcome of multiple fields (and possible external/3th party value) calculations?
Example with condition:
I want to filter the results based on the average of 5 numeric fields. So i need to add them up and divide them by 5 and if that outcome < 8 i do not want to use the entity.
Example sort with external API value:
I want to sort the results based on a calculation with an external API value. So lets say i have a numeric field in my entity with the value of 10. The external API gives me a value of 30. The calculation would be 30 – 10 = 20.
Now for my second entity the numeric field value equals 5 and the API sais 20. The calculation would be 20-5=15.
Now i want to sort the results from highest to lowest. So in this case the first entity should be first because the outcome of the calculation was 20 and for the second entity it was 15 so it should come second.