TOKEN "stats_page" READ TOKEN "axis" READ NODE _top_locations_0 SQL > % select location, uniqExact(session_id) as visits from _mv_hits h inner join filtered_sessions fs on fs.session_id = h.session_id where site_uuid = {{String(site_uuid, 'mock_site_uuid', description="Tenant ID", required=True)}} {% if defined(member_status) %} and member_status IN ( select arrayJoin( {{ Array(member_status, "'undefined', 'free', 'paid'", description="Member status to filter on", required=False) }} || if('paid' IN {{ Array(member_status) }}, ['comped', 'gift'], []) ) ) {% end %} {% if defined(location) %} and location = {{ String(location, description="Location to filter on", required=False) }} {% end %} {% if defined(pathname) %} and pathname = {{ String(pathname, description="Pathname to filter on", required=False) }} {% end %} {% if defined(post_uuid) %} and post_uuid = {{ String(post_uuid, description="Post UUID to filter on", required=False) }} {% end %} {% if defined(gift_link) %}{% if gift_link == 'false' or gift_link == '0' %} and gift_link = '' {% else %} and gift_link != '' {% end %}{% end %} group by location order by visits desc limit {{ Int32(skip, 0) }},{{ Int32(limit, 50) }} TYPE ENDPOINT