Hi @anon94532230 ,
I want to use this request because it’s a more efficient way to aggregate data and to order it on the way we want. I don’t understand why it’s not working because it’s a select at the end.
I used an unoptimized query (that takes 15 seconds to run):
SELECT u.id FROM "User" u
JOIN "Typebot" t ON u.id = t."ownerId"
WHERE (SELECT count(*) FROM "Result" r WHERE r."typebotId" = t.id LIMIT 30) >= 30
And I’ve optimized it like so:
WITH result_count AS (
SELECT r."typebotId", count(*) FROM "Result" r GROUP BY r."typebotId"
)
SELECT u.id FROM "User" u
JOIN "Typebot" t ON u.id = t."ownerId"
JOIN result_count r ON r."typebotId" = t.id
CREATE VIEW active_users AS
WITH result_count AS (
SELECT r."typebotId", count(*) FROM "Result" r GROUP BY r."typebotId"
)
SELECT u.id FROM "User" u
JOIN "Typebot" t ON u.id = t."ownerId"
JOIN result_count r ON r."typebotId" = t.id
Then add it to Forest Admin:
SELECT id FROM active_users
(This query works well when testing manually)
It still throws an error:
Object { isAdapterError: true, stack: "i@https://app.forestadmin.com/assets/vendor-aced6f74adaa0feb5a4c7819c3db2832.js:149:229579\nn@https://app.forestadmin.com/assets/vendor-aced6f74adaa0feb5a4c7819c3db2832.js:149:230337\nhandleResponse@https://app.forestadmin.com/assets/vendor-aced6f74adaa0feb5a4c7819c3db2832.js:149:236468\nhandleResponse@https://app.forestadmin.com/assets/client-f86a9449e70706f242d0470e24f0ef7f.js:1:4020776\nx@https://app.forestadmin.com/assets/vendor-aced6f74adaa0feb5a4c7819c3db2832.js:149:241063\najax/</u.error/s<@https://app.forestadmin.com/assets/vendor-aced6f74adaa0feb5a4c7819c3db2832.js:149:237741\najax/</u.error@https://app.forestadmin.com/assets/vendor-aced6f74adaa0feb5a4c7819c3db2832.js:149:237752\nl@https://app.forestadmin.com/assets/vendor-aced6f74adaa0feb5a4c7819c3db2832.js:48:24786\nfireWith@https://app.forestadmin.com/assets/vendor-aced6f74adaa0feb5a4c7819c3db2832.js:48:25534\nk@https://app.forestadmin.com/assets/vendor-aced6f74adaa0feb5a4c7819c3db2832.js:48:76509\nsend/n/<@https://app.forestadmin.com/assets/vendor-aced6f74adaa0feb5a4c7819c3db2832.js:48:78952\ni@https://app.forestadmin.com/assets/chunk.8.ba9810089db8238eff28.js:1:45893\n", description: undefined, fileName: "https://app.forestadmin.com/assets/vendor-aced6f74adaa0feb5a4c7819c3db2832.js", lineNumber: 149, message: "The adapter rejected the commit because it was invalid", name: "Error", number: undefined, errors: (1) […] }
chunk.8.ba9810089db8238eff28.js:1:47538
Hi @baptisteArno Sorry for the late response…
Where do you use these query? Inside a dashboard chart? If yes what is the chart type?
Can you give me the exact error please?
The log is not relevant.
Can you share with us the anonymized payload response of the request?