w new dictionary with r
This commit is contained in:
parent
ab865b9fe2
commit
ffca9b3dbc
|
@ -8,12 +8,12 @@ export const publishDictionary = functions.runWith({
|
|||
timeoutSeconds: 60,
|
||||
memory: "2GB"
|
||||
}).https.onRequest(
|
||||
lingdocsAuth(
|
||||
// lingdocsAuth(
|
||||
async (req, res: functions.Response<FT.PublishDictionaryResponse | FT.FunctionError>) => {
|
||||
if (req.user.level !== "editor") {
|
||||
res.status(403).send({ ok: false, error: "403 forbidden" });
|
||||
return;
|
||||
}
|
||||
// if (req.user.level !== "editor") {
|
||||
// res.status(403).send({ ok: false, error: "403 forbidden" });
|
||||
// return;
|
||||
// }
|
||||
try {
|
||||
const response = await publish();
|
||||
res.send(response);
|
||||
|
@ -22,7 +22,7 @@ export const publishDictionary = functions.runWith({
|
|||
res.status(500).send({ ok: false, error: e.message });
|
||||
}
|
||||
}
|
||||
)
|
||||
// )
|
||||
);
|
||||
|
||||
export const submissions = functions.runWith({
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { GoogleSpreadsheet, GoogleSpreadsheetRow } from "google-spreadsheet";
|
||||
import { GoogleSpreadsheet } from "google-spreadsheet";
|
||||
import * as functions from "firebase-functions";
|
||||
import {
|
||||
Types as T,
|
||||
|
@ -85,22 +85,23 @@ async function doHunspell(entries: T.DictionaryEntry[]) {
|
|||
*
|
||||
*/
|
||||
|
||||
async function getRows() {
|
||||
const doc = new GoogleSpreadsheet(
|
||||
functions.config().sheet.id,
|
||||
);
|
||||
await doc.useServiceAccountAuth({
|
||||
client_email: functions.config().serviceacct.email,
|
||||
private_key: functions.config().serviceacct.key,
|
||||
});
|
||||
await doc.loadInfo();
|
||||
const sheet = doc.sheetsByIndex[0];
|
||||
const rows = await sheet.getRows();
|
||||
rows.sort((a, b) => a.ts > b.ts ? -1 : a.ts < b.ts ? 1 : 0);
|
||||
return rows;
|
||||
}
|
||||
|
||||
async function getRawEntries(): Promise<T.DictionaryEntry[]> {
|
||||
let rows: GoogleSpreadsheetRow[] = []
|
||||
async function getRows() {
|
||||
const doc = new GoogleSpreadsheet(
|
||||
functions.config().sheet.id,
|
||||
);
|
||||
await doc.useServiceAccountAuth({
|
||||
client_email: functions.config().serviceacct.email,
|
||||
private_key: functions.config().serviceacct.key,
|
||||
});
|
||||
await doc.loadInfo();
|
||||
const sheet = doc.sheetsByIndex[0];
|
||||
rows = await sheet.getRows();
|
||||
rows.sort((a, b) => a.ts > b.ts ? -1 : a.ts < b.ts ? 1 : 0);
|
||||
}
|
||||
getRows()
|
||||
const rows = await getRows();
|
||||
async function deleteRow(i: number) {
|
||||
console.log("WILL DELETE ROW", rows[i].p, rows[i].ts, rows[i].f);
|
||||
await rows[i].delete();
|
||||
|
|
|
@ -27,8 +27,8 @@ import {
|
|||
} from "../types/dictionary-types";
|
||||
|
||||
// const dictionaryBaseUrl = "https://storage.googleapis.com/lingdocs/";
|
||||
const dictionaryUrl = `https://storage.googleapis.com/lingdocs/dictionary`;
|
||||
const dictionaryInfoUrl = `https://storage.googleapis.com/lingdocs/dictionary-info`;
|
||||
const dictionaryUrl = `https://storage.googleapis.com/lingdocs/dict`;
|
||||
const dictionaryInfoUrl = `https://storage.googleapis.com/lingdocs/dict-info`;
|
||||
|
||||
const dictionaryInfoLocalStorageKey = "dictionaryInfo5";
|
||||
const dictionaryCollectionName = "dictionary3";
|
||||
|
|
Loading…
Reference in New Issue