Skip to content

Instantly share code, notes, and snippets.

@clarkbw
Last active December 21, 2016 05:56
Show Gist options
  • Select an option

  • Save clarkbw/c844120085bfac0bb8238d9b4bac1d85 to your computer and use it in GitHub Desktop.

Select an option

Save clarkbw/c844120085bfac0bb8238d9b4bac1d85 to your computer and use it in GitHub Desktop.

Revisions

  1. clarkbw revised this gist Dec 21, 2016. 1 changed file with 4 additions and 16 deletions.
    20 changes: 4 additions & 16 deletions re-dash-csv.js
    Original file line number Diff line number Diff line change
    @@ -5,21 +5,9 @@ const YOUR_REDASH = "https://your.redash.io/api/queries/";

    // leave this
    const API_KEY = `?api_key=${API_KEY_ID}`;
    const QUERY_URL = `${YOUR_REDASH}${QUERY_ID}${API_KEY}`;
    const RESULT_URL = `${YOUR_REDASH}${QUERY_ID}/results.csv${API_KEY}`;

    // XXX: https://crossorigin.me is needed because this request contains no CORS headers
    d3.json(`https://crossorigin.me/${QUERY_URL}`, function(error, data) {
    d3.csv(RESULT_URL, function(data) {
    // you can remove this console log
    console.log('JSON', error, data);

    const id = data.latest_query_data_id;
    const RESULT_URL = `${YOUR_REDASH}${QUERY_ID}/results/${id}.csv${API_KEY}`;

    // you can remove this console log
    console.log('url', RESULT_URL);

    d3.csv(RESULT_URL, function(data) {
    // you can remove this console log
    console.log('CSV', data);
    });
    });
    console.log('CSV', data);
    });
  2. clarkbw revised this gist Sep 1, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion re-dash-csv.js
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,10 @@
    // edit these values
    const API_KEY_ID = "9352fd37f2f4ce923932c9c6328829a5be7093ea3d";
    const QUERY_ID = 1002;
    const YOUR_REDASH = "https://your.redash.io/api/queries/";

    // leave this
    const API_KEY = `?api_key=${API_KEY_ID}`;
    const YOUR_REDASH = "https://your.redash.io/api/queries/";
    const QUERY_URL = `${YOUR_REDASH}${QUERY_ID}${API_KEY}`;

    // XXX: https://crossorigin.me is needed because this request contains no CORS headers
  3. clarkbw created this gist Sep 1, 2016.
    25 changes: 25 additions & 0 deletions re-dash-csv.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    // edit these values
    const API_KEY_ID = "9352fd37f2f4ce923932c9c6328829a5be7093ea3d";
    const QUERY_ID = 1002;

    // leave this
    const API_KEY = `?api_key=${API_KEY_ID}`;
    const YOUR_REDASH = "https://your.redash.io/api/queries/";
    const QUERY_URL = `${YOUR_REDASH}${QUERY_ID}${API_KEY}`;

    // XXX: https://crossorigin.me is needed because this request contains no CORS headers
    d3.json(`https://crossorigin.me/${QUERY_URL}`, function(error, data) {
    // you can remove this console log
    console.log('JSON', error, data);

    const id = data.latest_query_data_id;
    const RESULT_URL = `${YOUR_REDASH}${QUERY_ID}/results/${id}.csv${API_KEY}`;

    // you can remove this console log
    console.log('url', RESULT_URL);

    d3.csv(RESULT_URL, function(data) {
    // you can remove this console log
    console.log('CSV', data);
    });
    });