Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Scheduling DSL Typescript Action #1157

Merged
merged 4 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()))));
}
Loading