Inline all the common table expressions to attempt to get better query plan
Inline all the common table expressions to attempt to get better query plan

- 20 seconds down to 1 second on prod data

databrary/databrary,databrary/databrary,databrary/databrary,databrary/databrary