Issue #115 - Write the current document id to disk

The idea is the metrics application can read this and know where
to point to, since the id will be changing week over week.
This commit is contained in:
Mike Taylor 2019-10-31 13:18:35 -05:00
Родитель 4754318b71
Коммит 02a7dd95d5
3 изменённых файлов: 16 добавлений и 1 удалений

1
.gitignore поставляемый
Просмотреть файл

@ -2,4 +2,5 @@ node_modules
data
config.json
credentials.json
currentDoc.json
.vscode/

Просмотреть файл

@ -1,5 +1,6 @@
const config = require('./config.json');
const fetch = require('node-fetch');
const fs = require('fs').promises;
const retry = require('promise-fn-retry');
const util = require('util');
@ -213,6 +214,16 @@ function getQueryDates(inputDate) {
return queryDates;
}
/**
* Write the passed in currentDocId to disk, so it can be read from other
* consumers.
* @param {string} currentDocId
*/
async function recordCurrentDoc(currentDocId) {
return fs.writeFile("currentDoc.json",
JSON.stringify({"currentDoc": currentDocId}), 'utf8');
}
/**
* Return the list of query dates until the present, starting
* at the specified date.
@ -249,5 +260,6 @@ module.exports = {
isMobile,
isDesktop,
isNotQA,
recordCurrentDoc,
resumeQueryDates,
}

Просмотреть файл

@ -66,8 +66,10 @@ const main = async () => {
for (const writer of writers) {
await spreadsheet.shareSheet(drive, currentDocId, writer);
console.log(`Current document ► https://docs.google.com/spreadsheets/d/${currentDocId}/edit`);
}
console.log(`Current document ► https://docs.google.com/spreadsheets/d/${currentDocId}/edit`);
await helpers.recordCurrentDoc(currentDocId);
}
}