I just updated to the latest version of the Data Explorer before posting this and I can confirm this issue is still present for me.
On the data explorer plugin there’s a feature that lets you expose queries to groups. I have done this for the query that counts consecutive days visited because I have users desperate to know how close they are to the xxx days visited badges.
The error seems to be caused by the request being sent (here I am showing the network inspector on firefox):
It appears to not be updating the parameter values as they are being entered (username=null, min_days=10 are the default parameters when you load the page). The console also gives an error “Uncaught TypeError: t is undefined” when either entering text into the username box or changing the min_days value. This line is throwing the error:
This is the best I can do of tracing the issue short of forking the repo and debugging each line. Just wanted to report the issue and also curious if others have the same problem.
Thanks @piffy for the report. We have recently made some changes to data-explorer plugin so this could very well be valid. I have tested multiple queries with a usernames input and have not ran into the issue linked in OP. Could you drop your query here that I could test it out?
--[params]
-- string :username
-- int :min_days = 10
WITH consecutive_visits AS (
SELECT user_id,
visited_at,
-- The value of s will be the same for each group of consecutive days
visited_at - (DENSE_RANK() OVER (PARTITION BY user_id ORDER BY visited_at))::int s
FROM user_visits
WHERE user_id = (SELECT id FROM users WHERE username = :username)
)
SELECT
MIN(visited_at) period_start,
COUNT(*) AS consecutive_days,
MAX(visited_at) period_end
FROM consecutive_visits
GROUP BY user_id, s
HAVING COUNT(*) >= :min_days
ORDER BY period_start DESC
I tried with safe mode on (official plugins only) and have the same issue.
As a fun extra tip while Isaac takes a look at that, you can also use the user_id parameter to get a swish auto-complete parameter box. eg:
-- [params]
-- user_id :user
-- int :min_days = 10
WITH consecutive_visits AS (
SELECT user_id,
visited_at,
-- The value of s will be the same for each group of consecutive days
visited_at - (DENSE_RANK() OVER (PARTITION BY user_id ORDER BY visited_at))::int s
FROM user_visits
WHERE user_id = :user
)
SELECT
MIN(visited_at) period_start,
COUNT(*) AS consecutive_days,
MAX(visited_at) period_end
FROM consecutive_visits
GROUP BY user_id, s
HAVING COUNT(*) >= :min_days
ORDER BY period_start DESC