steam-deck-calculator icon indicating copy to clipboard operation
steam-deck-calculator copied to clipboard

Live data importing

Open tjhorner opened this issue 2 years ago • 3 comments

The owner of the Google Sheet can use Google Apps Script to create a pseudo-API which can be used on the page so that people don't need to manually export as CSV then import to get the latest data from the sheet.

I created a simple example with the following Apps Script code:

function doGet(e) {
  const sheet = SpreadsheetApp.openById("1QqlSUpqhyBCBYeu_gW4w5vIxfcd7qablSviALDFJ0Dg").getSheetByName("Form Responses 1")
  const data = sheet.getSheetValues(1, 1, sheet.getLastRow(), 7)

  return ContentService.createTextOutput(JSON.stringify(data)).setMimeType(ContentService.MimeType.JSON)
}

Then I deployed it as a web API at this URL: https://script.google.com/macros/s/AKfycbzKT0Erw0y8QRwbVch4KEkjxV8m31d8qlmmlFH-E1QrTODMIYExkeVUKcpZ37CesO9P1Q/exec

It would require some tweaking to play nice with CORS and stuff, but it's definitely feasible. I unfortunately don't have the time to look into actually implementing this, but I hope this can help as a jumping-off point.

(Also, as an aside, Google Apps Script is very nice for hosting random one-off utilities for free)

tjhorner avatar Mar 07 '22 16:03 tjhorner

I looked at this option. I was initially going to do that, but decided against it because of API limits and ease of archiving. Also would mean I need to continuously update the model to remain consistent with new data.

mootw avatar Mar 26 '22 22:03 mootw

What about only pulling the day after emails get sent out?

brennanmuir avatar Apr 05 '22 21:04 brennanmuir

The best way to update would be to create a github action to re-deploy occasionally.

Since my model is fit to a specific data-set I plan to continue to manually update the data. There has been no indication so far that moov2 is dropping in accuracy, I plan to update the model as-needed from now on.

mootw avatar Apr 06 '22 03:04 mootw