Skip to content

Commit

Permalink
Merge pull request #1157 from NASA-AMMOS/fix/fix-scheduling-dsl-ts
Browse files Browse the repository at this point in the history
Fix Scheduling DSL Typescript Action
  • Loading branch information
Mythicaeda authored Sep 27, 2023
2 parents 50d69e6 + 7a292b3 commit bdf15b5
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion deployment/hasura/metadata/actions.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ type Query {
}

type Query {
schedulingDslTypescript(missionModelId: Int!): DslTypescriptResponse
schedulingDslTypescript(missionModelId: Int!, planId: Int): DslTypescriptResponse
}

type Query {
Expand Down
4 changes: 2 additions & 2 deletions e2e-tests/src/utilities/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ const gql = {
`,

GET_SCHEDULING_DSL_TYPESCRIPT: `#graphql
query GetSchedulingDslTypeScript($missionModelId: Int!) {
schedulingDslTypescript(missionModelId: $missionModelId) {
query GetSchedulingDslTypeScript($missionModelId: Int!, $planId: Int) {
schedulingDslTypescript(missionModelId: $missionModelId, planId: $planId) {
reason
status
typescriptFiles {
Expand Down
3 changes: 2 additions & 1 deletion e2e-tests/src/utilities/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,9 @@ const req = {
async getSchedulingDslTypeScript(
request: APIRequestContext,
missionModelId: number,
planId?: number
): Promise<SchedulingDslTypesResponse> {
const data = await req.hasura(request, gql.GET_SCHEDULING_DSL_TYPESCRIPT, { missionModelId: missionModelId });
const data = await req.hasura(request, gql.GET_SCHEDULING_DSL_TYPESCRIPT, { missionModelId: missionModelId, planId: planId });
const { schedulingDslTypescript } = data;
return schedulingDslTypescript;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.util.List;
import java.util.Objects;
import static gov.nasa.jpl.aerie.scheduler.server.http.ResponseSerializers.*;
import static gov.nasa.jpl.aerie.scheduler.server.http.SchedulerParsers.hasuraMissionModelIdActionP;
import static gov.nasa.jpl.aerie.scheduler.server.http.SchedulerParsers.hasuraSchedulingDSLTypescriptActionP;
import static gov.nasa.jpl.aerie.scheduler.server.http.SchedulerParsers.hasuraSpecificationActionP;
import static io.javalin.apibuilder.ApiBuilder.*;
import gov.nasa.jpl.aerie.json.JsonParser;
Expand Down Expand Up @@ -116,7 +116,7 @@ private void schedule(final Context ctx) {
*/
private void getSchedulingDslTypescript(final Context ctx) {
try {
final var body = parseJson(ctx.body(), hasuraMissionModelIdActionP);
final var body = parseJson(ctx.body(), hasuraSchedulingDSLTypescriptActionP);
final var missionModelId = body.input().missionModelId();
final var planId = body.input().planId();
final var response = this.generateSchedulingLibAction.run(missionModelId, planId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import static gov.nasa.jpl.aerie.json.BasicParsers.anyP;
import static gov.nasa.jpl.aerie.json.BasicParsers.longP;
import static gov.nasa.jpl.aerie.json.BasicParsers.nullableP;
import static gov.nasa.jpl.aerie.json.BasicParsers.productP;
import static gov.nasa.jpl.aerie.json.BasicParsers.stringP;
import static gov.nasa.jpl.aerie.json.Uncurry.tuple;
Expand Down Expand Up @@ -98,11 +99,11 @@ private static <I extends HasuraAction.Input> JsonParser<HasuraAction<I>> hasura
/**
* parser for a hasura action that accepts a mission model id as its sole input, along with normal hasura session details
*/
public static final JsonParser<HasuraAction<HasuraAction.MissionModelIdInput>> hasuraMissionModelIdActionP
public static final JsonParser<HasuraAction<HasuraAction.MissionModelIdInput>> hasuraSchedulingDSLTypescriptActionP
= hasuraActionF(productP
.field("missionModelId", missionModelIdP)
.optionalField("planId", planIdP)
.optionalField("planId", nullableP(planIdP))
.map(
untuple(HasuraAction.MissionModelIdInput::new),
input -> tuple(input.missionModelId(), input.planId())));
untuple((missionModelId, planId) -> new HasuraAction.MissionModelIdInput(missionModelId, planId.flatMap($->$))),
input -> tuple(input.missionModelId(), Optional.of(input.planId()))));
}

0 comments on commit bdf15b5

Please sign in to comment.