Skip to content

Commit

Permalink
Add BurstCube TOO API endpoints
Browse files Browse the repository at this point in the history
Add Validation to AstropyTime

Add FOV check to BurstCubeTOO and other fixes

Change healpix_order to healpix_scheme

Compare ephem times in unix time as comparing freeform astropy time object can cause this to fail due to minute differences that create an out of bounds issue with the assertion in get_slice

Fixes for modified_on/by

Remove history table stuff for now

Fix security for burstcube TOO

Updates for mypy and cleanups

Update import sorts

Import sort

Remove debug print statement

Simplify database write/update

Simplify database write/update

Fix check for existing TOO

Change BurstCubeTOO PUT to have the same arguments as POST, so we can use it to upload updated HEALPix

Remove excess docstring from schema

Reconfigure BurstCubeTOO to redo constraints check if PUT updates coordinates

Change how uploads are done in the API

Update TOO PUT schema

Trap uploads of bad HEALPix files

Fix bug

Make schema and api return astropy native values

Simplify requests.py

Move to astropy native in schema. Clean up docstrings

Clean up code reuse in BurstCubeTOO

Json email selections (nasa-gcn#1977)

Bump usehooks-ts from 2.15.0 to 2.15.1

Bumps [usehooks-ts](https://github.com/juliencrn/usehooks-ts) from 2.15.0 to 2.15.1.
- [Release notes](https://github.com/juliencrn/usehooks-ts/releases)
- [Commits](https://github.com/juliencrn/usehooks-ts/compare/[email protected]@2.15.1)

---
updated-dependencies:
- dependency-name: usehooks-ts
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

Bump tiny-invariant from 1.3.1 to 1.3.3

Bumps [tiny-invariant](https://github.com/alexreardon/tiny-invariant) from 1.3.1 to 1.3.3.
- [Release notes](https://github.com/alexreardon/tiny-invariant/releases)
- [Commits](alexreardon/tiny-invariant@v1.3.1...v1.3.3)

---
updated-dependencies:
- dependency-name: tiny-invariant
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

Support for reading gzipped fits files. Refactor reused code.

Remove superfluous entries in app.arc

Make BurstCubeTOO a dataclass to remove the init stuff

Differentiate username and created by

Back to username

Remove a space in a comment.

Compare jd instead of unix as it should always be consistent

Put table into a property that can be set for pytest

Don't hardcode TOO table name

Clean up docstring

Move table write into BurstCubeTOO

Move BurstCubeTOOModel into schema.py

Fix imports

Remove types in docstrings

Adds a confirmation alert (nasa-gcn#1957)

* Adds a confirmation alert

* Return intent and rename newItem to newCircular

Better sentence text, adds heading

Bump es5-ext from 0.10.61 to 0.10.63

Bumps [es5-ext](https://github.com/medikoo/es5-ext) from 0.10.61 to 0.10.63.
- [Release notes](https://github.com/medikoo/es5-ext/releases)
- [Changelog](https://github.com/medikoo/es5-ext/blob/main/CHANGELOG.md)
- [Commits](medikoo/es5-ext@v0.10.61...v0.10.63)

---
updated-dependencies:
- dependency-name: es5-ext
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Announcement template (nasa-gcn#1958)

Code of Conduct (nasa-gcn#1635)

Docstring cleanups

Fix use of old style Config in Pydantic model

Add pytest to check CRUD operations on BurstCubeTOO

Add check for SPACETRACK credentials

Fix reject_reason

Add old TOO rejection pytest

Add test for double submission

Add test for double submission

Mock BurstCubeTLE so that we don't have to spam celestak or spacetrack

Add pytest-mock requirement for testing

Revert tle.py

Mypy fixes

Docstring fix

Fix test time to a value that matches the test TLE
  • Loading branch information
jak574 committed Feb 29, 2024
1 parent fa5dab7 commit c043a60
Show file tree
Hide file tree
Showing 24 changed files with 1,593 additions and 36 deletions.
3 changes: 3 additions & 0 deletions app.arc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ acrossapi_tle
tle1 String
tle2 String

burstcube_too
id *String

sessions
_idx *String
_ttl TTL
Expand Down
5 changes: 5 additions & 0 deletions app/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ export function topicToFormatAndNoticeType(topic: string): {
noticeFormat: string
noticeType: string
} {
if (topic.startsWith('gcn.notices.') || topic === 'igwn.gwalert')
return {
noticeFormat: 'json',
noticeType: topic,
}
const splitString = topic.split('.')
return { noticeFormat: splitString[2], noticeType: splitString[3] }
}
Expand Down
29 changes: 22 additions & 7 deletions app/routes/_gcn.circulars._archive._index/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
useSubmit,
} from '@remix-run/react'
import {
Alert,
Button,
ButtonGroup,
Icon,
Expand Down Expand Up @@ -93,7 +94,7 @@ export async function action({ request }: ActionFunctionArgs) {
const user = await getUser(request)
const circularId = getFormDataString(data, 'circularId')

let result
let newCircular
const props = { body, subject, ...(format ? { format } : {}) }
switch (intent) {
case 'correction':
Expand All @@ -103,7 +104,7 @@ export async function action({ request }: ActionFunctionArgs) {
{ circularId: parseFloat(circularId), ...props },
user
)
result = null
newCircular = null
break
case 'edit':
if (!circularId)
Expand All @@ -115,24 +116,27 @@ export async function action({ request }: ActionFunctionArgs) {
},
user
)
result = await get(parseFloat(circularId))
newCircular = await get(parseFloat(circularId))
break
case 'new':
result = await put({ ...props, submittedHow: 'web' }, user)
newCircular = await put({ ...props, submittedHow: 'web' }, user)
break
default:
break
}
return result
return { newCircular, intent }
}

export default function () {
const newItem = useActionData<typeof action>()
const result = useActionData<typeof action>()
const { items, page, totalPages, totalItems, requestedChangeCount } =
useLoaderData<typeof loader>()

// Concatenate items from the action and loader functions
const allItems = [...(newItem ? [newItem] : []), ...(items || [])]
const allItems = [
...(result?.newCircular ? [result.newCircular] : []),
...(items || []),
]

const [searchParams] = useSearchParams()
const userIsModerator = useModStatus()
Expand All @@ -158,6 +162,17 @@ export default function () {

return (
<>
{result?.intent === 'correction' && (
<Alert
type={'success'}
headingLevel={'h1'}
slim
heading="Request Submitted"
>
Thank you for your correction. A GCN Circulars moderator will review
it shortly.
</Alert>
)}
<CircularsHeader />
{userIsModerator && requestedChangeCount > 0 && (
<Link to="moderation" className="usa-button usa-button--outline">
Expand Down
34 changes: 34 additions & 0 deletions app/routes/_gcn.docs.code-of-conduct.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
handle:
breadcrumb: Code of Conduct
---

# Code of Conduct

GCN Notices and Circulars are rapid communications which are by definition preliminary, and submitted as best-effort for the accuracy of their content. They are citable in publications, but are not peer reviewed.

The sharing of preliminary analysis and results in an open and respectful manner enables the productive exchange of information and ideas. Notices and Circulars contain factual information on observations and analysis of astronomical transients, not opinions, speculation, or disagreements with individuals or groups. The Circulars [style guide](/circulars/styleguide) provides additional criteria and community standards for Circular content.

GCN is committed to adhere to the [NASA Astrophysics Statement of Principles](https://cor.gsfc.nasa.gov/docs/HQ/NASA-Astrophysics-Statement-of-Principles-Nov2022.pdf).

## Retractions

If an initial automated or manually-generated Notice/Circular is later deemed to be misclassified as an astronomical object, the generating team should promptly submit another Notice/Circular informing the community of the retracted claim.

## Errata

Circulars authors can request edits to their own archived Circulars to correct inaccurate information, especially when the correction is important for the follow-up community's activities. These may include author lists, subject corrections, typos, and incorrect citations. This capability should not be used to add details of new observations or analysis &mdash; instead users should submit new Circulars with subjects noting "refined analysis" or "additional observations". To request corrections, navigate to the archive page for that particular circular, and select "Request Correction." The GCN team moderators will review the requested correction, and may contact the submitter for their concurrence.

## Reproducing GCN Notices or Circulars in External Archives

The GCN team welcomes cross-compatibility between community astronomical resources. GCN Circulars are scholarly publications and that and the expectations of scientific conduct for citing and reproducing them apply. If GCN Notices, Circulars, or their data are used in other systems, please link back to the original source materal at https://gcn.nasa.gov or https://gcn.gsfc.nasa.gov.

## Enforcement

The GCN system and community aim to foster an inclusive environment for the exchange of information and ideas. Mistakes are completely understandable in these forms of rapid communication, and the GCN team is happy to work with users to correct any unintentional errors. GCN will not tolerate users who are intentionally disrespectful, misrepresent data or analysis, plagiarize, or reproduce data or analysis without permission of the originator or proper citation.

Circulars submitting privileges are granted for new users via the GCN [peer endorsement system](/user/endorsements). Any user found to intentionally violate these policies will have their Circulars/Notices submission privileges revoked. This may lead to a review of the peer endorser who approved the offending user.

## Acknowledgement

The GCN team requests that any presentation, publication, or document that mentions the GCN system, specific GCN Circulars or Notices, to please reference the General Coordinates Network (https://gcn.nasa.gov) and cite Circulars using bibliographic records from the [SAO/NASA Astrophysics Data System (ADS)](https://ui.adsabs.harvard.edu).
3 changes: 3 additions & 0 deletions app/routes/_gcn.docs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ export default function () {
]}
/>
</>,
<NavLink key="code-of-conduct" to="code-of-conduct">
Code of Conduct
</NavLink>,
<>
<NavLink key="contributing" to="contributing">
Contributing
Expand Down
47 changes: 46 additions & 1 deletion app/routes/_gcn.news.email.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
Button,
ButtonGroup,
FormGroup,
Icon,
InputGroup,
InputPrefix,
TextInput,
Expand All @@ -21,6 +22,7 @@ import { useState } from 'react'

import { getUser } from './_gcn._auth/user.server'
import { moderatorGroup } from './_gcn.circulars/circulars.server'
import { announcementAppendedText } from './_gcn.user.email/email_announcements'
import { sendAnnouncementEmail } from './_gcn.user.email/email_announcements.server'
import { getFormDataString } from '~/lib/utils'

Expand All @@ -45,8 +47,11 @@ export async function action({ request }: ActionFunctionArgs) {
export default function () {
const [subjectValid, setSubjectValid] = useState(false)
const [bodyValid, setBodyValid] = useState(false)
const [showAppendedText, toggleShowAppendedText] = useState(false)
const valid = subjectValid && bodyValid
const submitted = useActionData<typeof action>()
const defaultBody =
'The GCN Team is pleased to announce a new feature on https://gcn.nasa.gov that ...'
return (
<>
<h1>GCN News Announcement</h1>
Expand Down Expand Up @@ -75,33 +80,73 @@ export default function () {
'usa-input--success': subjectValid,
})}
>
<InputPrefix className="wide-input-prefix">Subject</InputPrefix>
<InputPrefix
className="wide-input-prefix"
aria-describedby="subjectDescription"
>
Subject
</InputPrefix>
<TextInput
autoFocus
className="maxw-full"
name="subject"
id="subject"
type="text"
defaultValue={'GCN Announcement: [NEW FEATURE]'}
required={true}
onChange={({ target: { value } }) => {
setSubjectValid(Boolean(value))
}}
/>
</InputGroup>
<div className="text-base margin-bottom-1" id="subjectDescription">
<small>
Please replace "[New Feature]" with the appropriate title
</small>
</div>
<label hidden htmlFor="body">
Body
</label>
<Textarea
name="body"
id="body"
required={true}
defaultValue={defaultBody}
className={classnames('maxw-full', {
'usa-input--success': bodyValid,
})}
onChange={({ target: { value } }) => {
setBodyValid(Boolean(value))
}}
aria-describedby="bodyDescription"
/>
<div className="text-base margin-bottom-1" id="bodyDescription">
<small>
The submitted body text will have additional email footer content
appended automatically.{' '}
<Button
unstyled
type="button"
className="usa-link"
aria-expanded={showAppendedText}
onClick={() => toggleShowAppendedText(!showAppendedText)}
>
<small>
Appended Text&nbsp;
{showAppendedText ? (
<Icon.ExpandLess role="presentation" />
) : (
<Icon.ExpandMore role="presentation" />
)}
</small>
</Button>
</small>
{showAppendedText && (
<div className="text-base padding-x-2 padding-bottom-2 text-pre-wrap">
{announcementAppendedText}
</div>
)}
</div>
<ButtonGroup>
<Link to={`/news`} className="usa-button usa-button--outline">
Back
Expand Down
22 changes: 16 additions & 6 deletions app/routes/_gcn.user.email.edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { type NoticeFormat, NoticeFormatInput } from '~/components/NoticeFormat'
import { NoticeTypeCheckboxes } from '~/components/NoticeTypeCheckboxes/NoticeTypeCheckboxes'
import { ReCAPTCHA, verifyRecaptcha } from '~/components/ReCAPTCHA'
import { formatAndNoticeTypeToTopic } from '~/lib/utils'
import { useRecaptchaSiteKey } from '~/root'
import { useFeature, useRecaptchaSiteKey } from '~/root'
import type { BreadcrumbHandle } from '~/root/Title'
import { getUser } from '~/routes/_gcn._auth/user.server'

Expand All @@ -59,9 +59,12 @@ export async function action({ request }: ActionFunctionArgs) {
} = Object.fromEntries(data)
if (intent !== 'delete') await verifyRecaptcha(recaptchaResponse?.toString())
const noticeTypes = Object.keys(rest)
const topics = noticeTypes.map((noticeType) =>
formatAndNoticeTypeToTopic(noticeFormat.toString(), noticeType)
)
const topics =
noticeFormat == 'json'
? noticeTypes
: noticeTypes.map((noticeType) =>
formatAndNoticeTypeToTopic(noticeFormat.toString(), noticeType)
)
const emailNotification: EmailNotification = {
name: name.toString(),
recipient: recipient.toString(),
Expand Down Expand Up @@ -119,6 +122,7 @@ export default function () {
const [recipientValid, setRecipientValid] = useState(defaultRecipientValid)
const [alertsValid, setAlertsValid] = useState(false)
const [recaptchaValid, setRecaptchaValid] = useState(!useRecaptchaSiteKey())
const [defaultFormat, setFormat] = useState<NoticeFormat>(format)

return (
<Form method="POST">
Expand Down Expand Up @@ -160,12 +164,18 @@ export default function () {
onChange={(e) => setRecipientValid(Boolean(e.target.value))}
/>
<Label htmlFor="format">Format</Label>
<NoticeFormatInput name="noticeFormat" value={format} showJson={false} />
<NoticeFormatInput
name="noticeFormat"
value={defaultFormat}
showJson={useFeature('JSON_NOTICES')}
onChange={setFormat}
/>
<Label htmlFor="noticeTypes">Types</Label>
<NoticeTypeCheckboxes
selectedFormat={defaultFormat}
defaultSelected={notification.noticeTypes}
validationFunction={setAlertsValid}
></NoticeTypeCheckboxes>
/>
<ReCAPTCHA
onChange={(value) => {
setRecaptchaValid(Boolean(value))
Expand Down
11 changes: 10 additions & 1 deletion app/routes/_gcn.user.email/email_announcements.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
import { tables } from '@architect/functions'
import type { DynamoDBDocument } from '@aws-sdk/lib-dynamodb'
import { paginateQuery, paginateScan } from '@aws-sdk/lib-dynamodb'
import { dedent } from 'ts-dedent'

import type { User } from '../_gcn._auth/user.server'
import { moderatorGroup } from '../_gcn.circulars/circulars.server'
import { announcementAppendedText } from './email_announcements'
import { sendEmailBulk } from '~/lib/email.server'

export async function createAnnouncementSubsciption(
Expand Down Expand Up @@ -68,11 +70,18 @@ export async function sendAnnouncementEmail(
getLegacyAnnouncementReceiverEmails(),
])

const formattedBody = dedent`
${body}
${announcementAppendedText}
`

await sendEmailBulk({
fromName: 'GCN Announcements',
to: [...emails, ...legacyEmails],
subject,
body,
body: formattedBody,
topic: 'announcements',
})
}
Expand Down
17 changes: 17 additions & 0 deletions app/routes/_gcn.user.email/email_announcements.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*!
* Copyright © 2023 United States Government as represented by the
* Administrator of the National Aeronautics and Space Administration.
* All Rights Reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/

export const announcementAppendedText = `
For more details on this new feature and an archive of GCN news and announcements, see https://gcn.nasa.gov/news.
For questions, issues, or bug reports, please contact us via:
- Contact form:
https://gcn.nasa.gov/contact
- GitHub issue tracker:
https://github.com/nasa-gcn/gcn.nasa.gov/issues
`
Loading

0 comments on commit c043a60

Please sign in to comment.