Skip to content

Commit

Permalink
puts circulars kafka stuff behind feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
dakota002 authored and lpsinger committed Jun 3, 2024
1 parent 6413981 commit 3410efd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
7 changes: 5 additions & 2 deletions app/components/NoticeTypeCheckboxes/NoticeTypeCheckboxes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useState } from 'react'
import type { NoticeFormat } from '../NoticeFormat'
import { NestedCheckboxes } from '../nested-checkboxes/NestedCheckboxes'
import { triggerRate } from './rates'
import { useFeature } from '~/root'

function humanizedCount(count: number, singular: string, plural?: string) {
const noun = count === 1 ? singular : plural ?? `${singular}s`
Expand Down Expand Up @@ -182,8 +183,7 @@ const NoticeTypeLinks: { [key: string]: string | undefined } = {
Other: undefined,
}

const JsonNoticeTypes = {
Circulars: ['gcn.circulars'],
const JsonNoticeTypes: { [key: string]: string[] } = {
IceCube: ['gcn.notices.icecube.lvk_nu_track_search'],
LVK: ['igwn.gwalert'],
Swift: ['gcn.notices.swift.bat.guano'],
Expand Down Expand Up @@ -213,6 +213,9 @@ export function NoticeTypeCheckboxes({
const [selectedCounter, setSelectedCounter] = useState(0)
const [alertEstimate, setAlertEstimate] = useState(0)

if (useFeature('CIRCULARS_KAFKA'))
JsonNoticeTypes['Circulars'] = ['gcn.circulars']

const counterfunction = (childRef: HTMLInputElement) => {
if (childRef.checked) {
userSelected.add(childRef.name)
Expand Down
10 changes: 6 additions & 4 deletions app/table-streams/circulars/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import type {
} from 'aws-lambda'

import { sendEmailBulk } from '~/lib/email.server'
import { origin } from '~/lib/env.server'
import { feature, origin } from '~/lib/env.server'
import { send as sendKafka } from '~/lib/kafka.server'
import { createTriggerHandler } from '~/lib/lambdaTrigger.server'
import type { Circular } from '~/routes/circulars/circulars.lib'
Expand Down Expand Up @@ -123,9 +123,11 @@ export const handler = createTriggerHandler(
if (eventName === 'INSERT') {
promises.push(send(circular))
const { sub, ...cleanedCircular } = circular
promises.push(
sendKafka('gcn.circulars', JSON.stringify(cleanedCircular))
)
if (feature('CIRCULARS_KAFKA')) {
promises.push(
sendKafka('gcn.circulars', JSON.stringify(cleanedCircular))
)
}
}
}

Expand Down

0 comments on commit 3410efd

Please sign in to comment.