Skip to content

Commit

Permalink
add SVOM source name subject matcher
Browse files Browse the repository at this point in the history
  • Loading branch information
jracusin authored and lpsinger committed Feb 20, 2025
1 parent d7160ea commit fdcee59
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
51 changes: 51 additions & 0 deletions __tests__/circulars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ describe('parseEventFromSubject', () => {
const ztfEvent = 'ZTF23aabmzlp'
const epEvent = 'EP241119a'
const frbEvent = 'FRB 20250206A'
const svomEvent = 'sb25021804'

test('handles nonsense subject cases', () => {
expect(parseEventFromSubject('zawxdrcftvgbhnjm')).toBe(undefined)
Expand Down Expand Up @@ -623,6 +624,56 @@ describe('parseEventFromSubject', () => {
expect(parseEventFromSubject(frbSubjectWithHyphen)).toBe(frbEvent)
})
})

describe('SVOM', () => {
test('handles SVOM event names', () => {
const svomSubject =
'SVOM/sb25021804: SVOM detection of a long X-ray transient'
expect(parseEventFromSubject(svomSubject)).toBe(svomEvent)
})

test('handles SVOM event names in misc positions', () => {
const svomSubjectWithNoSpace =
'SVOM detection: SVOM/sb25021804 a long X-ray transient'
expect(parseEventFromSubject(svomSubjectWithNoSpace)).toBe(svomEvent)
})

test('handles SVOM event names with space', () => {
const svomSubjectWithSpace =
'SVOM/sb 25021804: SVOM detection of a long X-ray transient'
expect(parseEventFromSubject(svomSubjectWithSpace)).toBe(svomEvent)
})

test('handles SVOM event names with spaces in misc positions', () => {
const svomSubjectWithSpace =
'SVOM detection: SVOM/sb25021804 a long X-ray transient'
expect(parseEventFromSubject(svomSubjectWithSpace)).toBe(svomEvent)
})

test('handles SVOM event name with an underscore', () => {
const svomSubjectWithUnderscore =
'SVOM/sb_25021804: SVOM detection of a long X-ray transient'
expect(parseEventFromSubject(svomSubjectWithUnderscore)).toBe(svomEvent)
})

test('handles SVOM event names with an underscore in misc positions', () => {
const svomSubjectWithUnderscore =
'SVOM detection: SVOM/sb25021804 a long X-ray transient'
expect(parseEventFromSubject(svomSubjectWithUnderscore)).toBe(svomEvent)
})

test('handles SVOM event name with a hyphen', () => {
const svomSubjectWithHyphen =
'SVOM/sb-25021804: SVOM detection of a long X-ray transient'
expect(parseEventFromSubject(svomSubjectWithHyphen)).toBe(svomEvent)
})

test('handles SVOM event name with a hyphen in misc positions', () => {
const svomSubjectWithHyphen =
'SVOM detection: SVOM/sb-25021804 a long X-ray transient'
expect(parseEventFromSubject(svomSubjectWithHyphen)).toBe(svomEvent)
})
})
})

describe('emailIsAutoReply', () => {
Expand Down
1 change: 1 addition & 0 deletions app/routes/circulars/circulars.lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const subjectMatchers: SubjectMatcher[] = [
],
[/EP[.\s_-]*(\d{6}[a-z])/i, ([, id]) => `EP${id}`],
[/FRB[.\s_-]*(\d{8}[a-z])/i, ([, id]) => `FRB ${id}`.toUpperCase()],
[/sb[.\s_-]*(\d{8})/i, ([, id]) => `sb${id}`],
]

/** Format a Circular as plain text. */
Expand Down

0 comments on commit fdcee59

Please sign in to comment.