-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Imports can have additional senses (#404)
* use the same column names for all other example sentences even with multiple senses * allow multiples sentences linked to the same sense * check for dev server when importing entries * type import row everywhere, add speaker right away when new speaker encountered --------- Co-authored-by: livingtongues <[email protected]> Co-authored-by: Jacob Bowdoin <[email protected]>
- Loading branch information
1 parent
4d584dc
commit 3f4890a
Showing
47 changed files
with
2,832 additions
and
641 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ logs | |
service-account* | ||
.env | ||
sheets-viewer-SA.json | ||
.env.supabase |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,31 @@ | ||
import algoliasearch from 'algoliasearch'; | ||
import { projectId } from '../config'; | ||
import { adminKey } from './algolia-admin-key.json'; | ||
import { AlgoliaEntry } from '@living-dictionaries/types'; | ||
import algoliasearch from 'algoliasearch' | ||
import type { AlgoliaEntry } from '@living-dictionaries/types' | ||
import { projectId } from '../config-firebase' | ||
import { adminKey } from './algolia-admin-key.json' | ||
|
||
const ALGOLIA_APP_ID = 'XCVBAYSYXD'; | ||
const ALGOLIA_APP_ID = 'XCVBAYSYXD' | ||
|
||
export const client = algoliasearch(ALGOLIA_APP_ID, adminKey); | ||
export const client = algoliasearch(ALGOLIA_APP_ID, adminKey) | ||
|
||
const index = client.initIndex( | ||
projectId === 'talking-dictionaries-dev' ? 'entries_dev' : 'entries_prod' | ||
); | ||
projectId === 'talking-dictionaries-dev' ? 'entries_dev' : 'entries_prod', | ||
) | ||
|
||
const MAX_CHUNK_SIZE = 3000; | ||
const MAX_CHUNK_SIZE = 3000 | ||
// https://www.algolia.com/doc/api-reference/api-methods/add-objects/#examples | ||
// if forced to iterate instead of save all at once, take note of the rate limiting at 5000 backlogged requests https://www.algolia.com/doc/faq/indexing/is-there-a-rate-limit/ | ||
|
||
export async function updateIndex(entries: AlgoliaEntry[]) { | ||
try { | ||
for (let startOfChunkIndex = 0; startOfChunkIndex < entries.length; startOfChunkIndex += MAX_CHUNK_SIZE) { | ||
const endOfChunk = startOfChunkIndex + MAX_CHUNK_SIZE; | ||
const chunk = entries.slice(startOfChunkIndex, endOfChunk); | ||
console.log({ startOfChunkIndex, endOfChunk, CHUNK_SIZE: MAX_CHUNK_SIZE, chunkLength: chunk.length }); | ||
const endOfChunk = startOfChunkIndex + MAX_CHUNK_SIZE | ||
const chunk = entries.slice(startOfChunkIndex, endOfChunk) | ||
console.log({ startOfChunkIndex, endOfChunk, CHUNK_SIZE: MAX_CHUNK_SIZE, chunkLength: chunk.length }) | ||
|
||
const { objectIDs } = await index.saveObjects(chunk); | ||
console.log(`Entries indexed: ${objectIDs.length}`); | ||
const { objectIDs } = await index.saveObjects(chunk) | ||
console.log(`Entries indexed: ${objectIDs.length}`) | ||
} | ||
} catch (err) { | ||
console.log(err); | ||
console.log(err) | ||
} | ||
|
||
} |
Oops, something went wrong.