Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/deploy-backend-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,12 @@ jobs:
GCP_SA_KEY: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}
ASSEMBLY_API_KEY: ${{ secrets.ASSEMBLY_API_KEY }}
PROJECT_ID: digital-testimony-dev

# Update Typesense Schema
- uses: google-github-actions/auth@v3
with:
credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}
- uses: google-github-actions/setup-gcloud@v3
- name: Update Typesense Schema
run: |
gcloud pubsub topics publish --project=digital-testimony-dev checkSearchIndexVersion --message='{"check": true}'
9 changes: 9 additions & 0 deletions .github/workflows/deploy-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,12 @@ jobs:
GCP_SA_KEY: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}
ASSEMBLY_API_KEY: ${{ secrets.ASSEMBLY_API_KEY }}
PROJECT_ID: digital-testimony-prod

# Update Typesense Schema
- uses: google-github-actions/auth@v3
with:
credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}
- uses: google-github-actions/setup-gcloud@v3
- name: Update Typesense Schema
run: |
gcloud pubsub topics publish --project=digital-testimony-prod checkSearchIndexVersion --message='{"check": true}'
2 changes: 2 additions & 0 deletions functions/src/search/SearchIndexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ export class SearchIndexer {
const { alias } = this.config
const isCollectionUpToDate =
this.collectionName === (await this.getCurrentCollectionName())
console.log(`Index for alias ${alias} up to date: ${isCollectionUpToDate}`)
if (!isCollectionUpToDate) {
console.log(`Scheduling upgrade for alias ${alias}`)
const upgradeDoc = db.doc(SearchIndexer.upgradePath(alias))
await upgradeDoc.delete()
await upgradeDoc.create({
Expand Down
2 changes: 1 addition & 1 deletion functions/src/search/checkSearchIndexVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { runWith } from "firebase-functions"
import { getRegisteredConfigs } from "./config"
import { SearchIndexer } from "./SearchIndexer"

/** Schedules index upgrades for each config if necessary. Requires a message
/** Schedules index upgrades for each config/alias(bills/hearing/testimony) if necessary. Requires a message
* wtih content `{ "check": true}` */
export const checkSearchIndexVersion = runWith({
secrets: ["TYPESENSE_API_KEY"]
Expand Down