Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backfill synonyms for all circulars once eventId has been backfilled #2662

Open
Courey opened this issue Nov 1, 2024 · 4 comments · May be fixed by #2735
Open

backfill synonyms for all circulars once eventId has been backfilled #2662

Courey opened this issue Nov 1, 2024 · 4 comments · May be fixed by #2735
Assignees

Comments

@Courey
Copy link
Contributor

Courey commented Nov 1, 2024

This needs to backfill a synonym record for all existing eventIds. it needs to create a synonym for each with a slug.

@Courey Courey added this to GCN Nov 1, 2024
@Courey Courey self-assigned this Nov 1, 2024
@Courey Courey converted this from a draft issue Nov 1, 2024
@Courey
Copy link
Contributor Author

Courey commented Nov 1, 2024

import { tables } from '@architect/functions'
import { ReturnValue } from '@aws-sdk/client-dynamodb'
import type { DynamoDBDocument } from '@aws-sdk/lib-dynamodb'
import { paginateScan, UpdateCommand } from '@aws-sdk/lib-dynamodb'

import {
  type Circular,
  parseEventFromSubject,
} from '~/routes/circulars/circulars.lib'

export async function backfill() {
  console.log('Starting backfill...')
  const db = await tables()
  const client = db._doc as unknown as DynamoDBDocument
  const TableName = db.name('circulars')
  const pages = paginateScan(
    { client },
    {
      TableName,
    }
  )
  for await (const page of pages) {
    for (const record of page.Items || []) {
      const circular = record as unknown as Circular
      const validEvent =
        circular.eventId || parseEventFromSubject(circular.subject)
      if (!circular.eventId && validEvent) {
         tryInitSynonym(validEvent)
      }
    }
  }
  console.log('... End backfill')
}
await backfill()

@Courey
Copy link
Contributor Author

Courey commented Nov 15, 2024

Blocked until eventIds are backfilled

@lpsinger
Copy link
Member

@Courey, would you please post that code snippet on a gist so that we can make line comments on it?

@Courey
Copy link
Contributor Author

Courey commented Nov 20, 2024

https://gist.github.com/Courey/7d0424b9a3cd0d30b54e88d6a1053960
This is the synonym only backfill

@lpsinger lpsinger added this to the Circulars Synonyms milestone Nov 22, 2024
@Courey Courey moved this from Blocked to In Review in GCN Nov 27, 2024
@Courey Courey linked a pull request Nov 27, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Review
Development

Successfully merging a pull request may close this issue.

2 participants