Query editor
WITHallPoolAnswers as (SELECTCAST(json_extract(answers, '$.timestamp') as INTEGER) as timestamp,CAST(json_extract(answers, '$.roundId') as INTEGER) as roundId,CAST(json_extract(answers, '$.question') as VARCHAR) as question,CASEWHEN contains(ARRAY['yes', 'true', 'valid', 'p2', '1'], lower(CAST(json_extract(answers, '$.answer') as VARCHAR))) THEN 'P2'WHEN contains(ARRAY['no', 'false', 'invalid', 'p1', '0'], lower(CAST(json_extract(answers, '$.answer') as VARCHAR))) THEN 'P1'ELSE CAST(json_extract(answers, '$.answer') as VARCHAR)END as answer,CAST(json_extract(answers, '$.ancillaryData') as VARCHAR) as ancillaryDataFROM UNNEST(CAST(json_parse(http_get('https://www.uma.rocks/api/getPoolAnswers')) AS array(json))) t(answers)ORDER BY roundId DESC)-- Remove rolled votes by keeping only the last answer (recognized by its roundId) for each dispute (recognized by its ancillaryData)SELECT l.*FROM allPoolAnswers lINNER JOIN (SELECTancillaryData, max(roundId) as latestFROM allPoolAnswersGROUP BY ancillaryData) ron l.roundId = r.latest and l.ancillaryData = r.ancillaryDataorder by l.roundId desc