From 3410efdeafc7eab3b2e9de03b8c1b8bf142f0ecf Mon Sep 17 00:00:00 2001 From: dakota002 Date: Mon, 3 Jun 2024 09:51:35 -0400 Subject: [PATCH] puts circulars kafka stuff behind feature flag --- .../NoticeTypeCheckboxes/NoticeTypeCheckboxes.tsx | 7 +++++-- app/table-streams/circulars/index.ts | 10 ++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/components/NoticeTypeCheckboxes/NoticeTypeCheckboxes.tsx b/app/components/NoticeTypeCheckboxes/NoticeTypeCheckboxes.tsx index 9bf7fa9d9..660e185c9 100644 --- a/app/components/NoticeTypeCheckboxes/NoticeTypeCheckboxes.tsx +++ b/app/components/NoticeTypeCheckboxes/NoticeTypeCheckboxes.tsx @@ -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` @@ -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'], @@ -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) diff --git a/app/table-streams/circulars/index.ts b/app/table-streams/circulars/index.ts index 6b6e2d215..f29b67a91 100644 --- a/app/table-streams/circulars/index.ts +++ b/app/table-streams/circulars/index.ts @@ -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' @@ -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)) + ) + } } }