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