Skip to content

Commit

Permalink
Use the new api to update observation time
Browse files Browse the repository at this point in the history
  • Loading branch information
cquiroz committed Aug 14, 2024
1 parent 2d3474d commit 69c3e31
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 32 deletions.
12 changes: 12 additions & 0 deletions explore/src/clue/scala/queries/common/ObsQueriesGQL.scala
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,18 @@ object ObsQueriesGQL:
}
"""

@GraphQL
trait UpdateObservationTimesMutation extends GraphQLOperation[ObservationDB]:
val document = """
mutation ($input: UpdateObservationsTimesInput!){
updateObservationsTimes(input: $input) {
observations {
id
}
}
}
"""

@GraphQL
trait CreateConfigurationMutation extends GraphQLOperation[ObservationDB]:
val document = s"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ object ObservationSubquery extends GraphQLSubquery.Typed[ObservationDB, Observat
subtitle
status
activeStatus
visualizationTime
observationTime
posAngleConstraint $PosAngleConstraintSubquery
targetEnvironment {
asterism {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ object ObsSummaryTable:
// Only expand if there are multiple targets
if (targets.sizeIs > 1)
targets.map: target =>
Expandable(ExpandedTargetRow(obs.id, target, obs.visualizationTime))
Expandable(ExpandedTargetRow(obs.id, target, obs.observationTime))
else Nil
)
.useReactTableWithStateStoreBy: (props, ctx, cols, rows) =>
Expand Down Expand Up @@ -401,8 +401,8 @@ object ObsSummaryTable:
this match
case r: ExpandedTargetRow => targetCoords(r.targetWithId, r.vizTime)
case r: ObsRow =>
asterismCoords(r.asterism, r.obs.visualizationTime)
.orElse(r.targetWithId.flatMap(t => targetCoords(t, r.obs.visualizationTime)))
asterismCoords(r.asterism, r.obs.observationTime)
.orElse(r.targetWithId.flatMap(t => targetCoords(t, r.obs.observationTime)))

private def targetCoords(twid: TargetWithId, vizTime: Option[Instant]): Option[Coordinates] =
Target.sidereal
Expand Down
4 changes: 2 additions & 2 deletions explore/src/main/scala/explore/tabs/ObsTabTiles.scala
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ object ObsTabTiles:
.useStateView(().ready)
.useStateView(ChartSelector.Closed)
.useEffectKeepResultWithDepsBy((p, _, _, _, _, _, _, _, _, _, _, _, _, _) =>
p.observation.model.get.visualizationTime
p.observation.model.get.observationTime
): (_, _, _, _, _, _, _, _, _, _, _, _, _, _) =>
vizTime => IO(vizTime.getOrElse(Instant.now()))
.render:
Expand Down Expand Up @@ -317,7 +317,7 @@ object ObsTabTiles:
props.observation.get.observingMode.map(_.toBasicConfiguration)

val vizTimeView: View[Option[Instant]] =
props.observation.model.zoom(Observation.visualizationTime)
props.observation.model.zoom(Observation.observationTime)

val asterismAsNel: Option[NonEmptyList[TargetWithId]] =
NonEmptyList.fromList:
Expand Down
4 changes: 2 additions & 2 deletions explore/src/main/scala/explore/tabs/TargetTabContents.scala
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ object TargetTabContents extends TwoPanels:
for
id <- idsToEdit.single
o <- a.observations.getValue(id)
t <- o.visualizationTime
t <- o.observationTime
yield t

def modVizTime(
Expand All @@ -208,7 +208,7 @@ object TargetTabContents extends TwoPanels:
ProgramSummaries.observations
.filterIndex((id: Observation.Id) => id === i)
.andThen(KeyedIndexedList.value)
.andThen(Observation.visualizationTime)
.andThen(Observation.observationTime)
.modify(mod)(ps)
)
.getOrElse(ps)
Expand Down
12 changes: 6 additions & 6 deletions explore/src/main/scala/queries/schemas/odb/ObsQueries.scala
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,17 @@ object ObsQueries:
}

def updateVisualizationTime[F[_]: Async](
obsIds: List[Observation.Id],
visualizationTime: Option[Instant]
obsIds: List[Observation.Id],
observationTime: Option[Instant]
)(using FetchClient[F, ObservationDB]): F[Unit] = {

val editInput = ObservationPropertiesInput(visualizationTime =
visualizationTime.flatMap(Timestamp.fromInstantTruncated).orUnassign
val editInput = ObservationTimesInput(observationTime =
observationTime.flatMap(Timestamp.fromInstantTruncated).orUnassign
)

UpdateObservationMutation[F]
UpdateObservationTimesMutation[F]
.execute(
UpdateObservationsInput(
UpdateObservationsTimesInput(
WHERE = obsIds.toWhereObservation.assign,
SET = editInput
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ trait ArbObservation:
o.timingWindows,
o.scienceRequirements,
o.observingMode,
o.visualizationTime,
o.observationTime,
o.posAngleConstraint,
o.wavelength,
o.groupId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ case class ElevationPlotOptions(
elevationPlotSkyBrightnessVisible: Visible,
elevationPlotLunarElevationVisible: Visible
) derives Eq:
def withDateAndSemesterOf(visualizationTime: Instant): ElevationPlotOptions =
val (date, semester) = ElevationPlotOptions.dateAndSemesterOf(visualizationTime.some, site)
def withDateAndSemesterOf(observationTime: Instant): ElevationPlotOptions =
val (date, semester) = ElevationPlotOptions.dateAndSemesterOf(observationTime.some, site)
copy(date = date, semester = semester)

def minInstant: Instant =
Expand Down Expand Up @@ -73,12 +73,12 @@ object ElevationPlotOptions:
Focus[ElevationPlotOptions](_.elevationPlotLunarElevationVisible)

private def dateAndSemesterOf(
visualizationTime: Option[Instant],
site: Site
observationTime: Option[Instant],
site: Site
): (LocalDate, Semester) =
val date: LocalDate =
ObservingNight
.fromSiteAndInstant(site, visualizationTime.getOrElse(Instant.now))
.fromSiteAndInstant(site, observationTime.getOrElse(Instant.now))
.toLocalDate
// if `fromLocalDate` returns None, date is out of range, so clamp
// semester to the Min and Max semesters
Expand All @@ -89,14 +89,14 @@ object ElevationPlotOptions:
(date, semester)

def default(
predefinedSite: Option[Site],
visualizationTime: Option[Instant],
coords: CoordinatesAtVizTime
predefinedSite: Option[Site],
observationTime: Option[Instant],
coords: CoordinatesAtVizTime
) =
val site: Site = predefinedSite.getOrElse(
if (coords.value.dec.toAngle.toSignedDoubleDegrees > -5) Site.GN else Site.GS
)
val (date, semester) = dateAndSemesterOf(visualizationTime, site)
val (date, semester) = dateAndSemesterOf(observationTime, site)

ElevationPlotOptions(
site,
Expand Down
14 changes: 8 additions & 6 deletions model/shared/src/main/scala/explore/model/Observation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ case class Observation(
attachmentIds: SortedSet[ObsAttachment.Id],
scienceRequirements: ScienceRequirements,
observingMode: Option[ObservingMode],
visualizationTime: Option[Instant],
observationTime: Option[Instant],
posAngleConstraint: PosAngleConstraint,
wavelength: Option[Wavelength],
groupId: Option[Group.Id],
Expand Down Expand Up @@ -98,14 +98,15 @@ case class Observation(
_,
_
) =>
val defaultMode =
val defaultMode =
GmosCcdMode(
defaultXBin,
defaultYBin,
GmosAmpCount.Twelve,
defaultAmpGain,
defaultAmpReadMode
)

val overridenMode: GmosCcdMode =
List(explicitXBin, explicitYBin, explicitAmpGain, explicitAmpReadMode).foldLeft(
defaultMode
Expand Down Expand Up @@ -142,14 +143,15 @@ case class Observation(
_,
_
) =>
val defaultMode =
val defaultMode =
GmosCcdMode(
defaultXBin,
defaultYBin,
GmosAmpCount.Twelve,
defaultAmpGain,
defaultAmpReadMode
)

val overridenMode: GmosCcdMode =
List(explicitXBin, explicitYBin, explicitAmpGain, explicitAmpReadMode).foldLeft(
defaultMode
Expand Down Expand Up @@ -183,7 +185,7 @@ object Observation:
val attachmentIds = Focus[Observation](_.attachmentIds)
val scienceRequirements = Focus[Observation](_.scienceRequirements)
val observingMode = Focus[Observation](_.observingMode)
val visualizationTime = Focus[Observation](_.visualizationTime)
val observationTime = Focus[Observation](_.observationTime)
val posAngleConstraint = Focus[Observation](_.posAngleConstraint)
val wavelength = Focus[Observation](_.wavelength)
val groupId = Focus[Observation](_.groupId)
Expand Down Expand Up @@ -213,7 +215,7 @@ object Observation:
attachmentIds <- c.get[List[AttachmentIdWrapper]]("obsAttachments")
scienceRequirements <- c.get[ScienceRequirements]("scienceRequirements")
observingMode <- c.get[Option[ObservingMode]]("observingMode")
visualizationTime <- c.get[Option[Timestamp]]("visualizationTime")
observationTime <- c.get[Option[Timestamp]]("observationTime")
posAngleConstraint <- c.get[PosAngleConstraint]("posAngleConstraint")
wavelength <- c.downField("scienceRequirements")
.downField("spectroscopy")
Expand All @@ -235,7 +237,7 @@ object Observation:
SortedSet.from(attachmentIds.map(_.id)),
scienceRequirements,
observingMode,
visualizationTime.map(_.toInstant),
observationTime.map(_.toInstant),
posAngleConstraint,
wavelength,
groupId,
Expand Down
4 changes: 2 additions & 2 deletions project/Versions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ object Versions {
val lucumaCatalog = "0.47.3"
val lucumaReact = "0.70.0"
val lucumaRefined = "0.1.3"
val lucumaSchemas = "0.94.1"
val lucumaOdbSchema = "0.11.13"
val lucumaSchemas = "0.95.0"
val lucumaOdbSchema = "0.11.14"
val lucumaSSO = "0.6.21"
val lucumaUI = "0.114.0"
val lucumaITC = "0.21.17"
Expand Down

0 comments on commit 69c3e31

Please sign in to comment.