NASA-AMMOS / aerie-cli

An unofficial CLI for interacting with Aerie planning software
MIT License
3 stars 4 forks source link

Find goal satisfaction from a plan #104

Open tydawson opened 9 months ago

tydawson commented 9 months ago

In order to meet some of the requirements of a Mission Sim Report MPST is developing, we needed a way to get goal satisfaction from any given plan.

Through discussions with Alex Greer and Megan Jones, it looks like the following queries could be ran to get the goal satisfaction of a plan:

First, find the spec_id from this query:

query MyQuery { scheduling_specification(where: {plan_id: {_eq: $plan_id}}) { id } }

Then feed that spec_id into this query:

query MyQuery { scheduling_goal_analysis(where: {request: {specification_id: {_eq: $spec_id}}}) { goal_id analysis_id satisfied satisfying_activities_aggregate { aggregate { count(distinct: false) } } } }

And it should give you:

{ "data": { "scheduling_goal_analysis": [ { "goal_id": 27, "analysis_id": 80, "satisfied": false, "satisfying_activities_aggregate": { "aggregate": { "count": 59 } } }, { "goal_id": 26, "analysis_id": 81, "satisfied": false, "satisfying_activities_aggregate": { "aggregate": { "count": 270 } } } ] } }

You can tell if a goal is satisfied because the "satisfied" field in the query response will say true, goals are partially satisfied if the "count" number is non-zero but "satisfied" is false. If count is 0 and "satisfied" is false the goals is unsatisfied.

You can get the names for the goal_ids in the response above using this query:

query MyQuery { scheduling_goal(where: {id: {_eq: 27}}) { author name revision id definition description created_date modified_date model_id last_modified_by } }

Ideally, we would just filter for the last run for each goal so the result does not show all scheduling goal run results in that plan. It should also return all the info of the goal for that run, from the last query.