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 data
config.json config.json
credentials.json credentials.json
currentDoc.json
.vscode/ .vscode/

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

@ -1,5 +1,6 @@
const config = require('./config.json'); const config = require('./config.json');
const fetch = require('node-fetch'); const fetch = require('node-fetch');
const fs = require('fs').promises;
const retry = require('promise-fn-retry'); const retry = require('promise-fn-retry');
const util = require('util'); const util = require('util');
@ -213,6 +214,16 @@ function getQueryDates(inputDate) {
return queryDates; 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 * Return the list of query dates until the present, starting
* at the specified date. * at the specified date.
@ -249,5 +260,6 @@ module.exports = {
isMobile, isMobile,
isDesktop, isDesktop,
isNotQA, isNotQA,
recordCurrentDoc,
resumeQueryDates, resumeQueryDates,
} }

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

@ -66,8 +66,10 @@ const main = async () => {
for (const writer of writers) { for (const writer of writers) {
await spreadsheet.shareSheet(drive, currentDocId, writer); 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);
} }
} }