Skip to content

Commit

Permalink
Update system jump risk on start
Browse files Browse the repository at this point in the history
  • Loading branch information
madmikeross committed Dec 23, 2023
1 parent b40a64a commit 7e061a9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ accepting requests. If routing isn't working properly, inspect the logs for the
`docker logs eve-graph-api-1`.

### Finding the shortest route

If you want to find the shortest route between two systems, say Jita and Amarr, simply issue a get request to
`localhost:8008/shortest-route/Jita/to/Amarr` (can be done in a browser, with curl, or via Postman).

### Finding a safe route

First you need to update the jump risks of each system by making a POST request to `localhost:8008/systems/risk`. This
will fetch kills and jumps for all systems in the last hour, and use those values to assign a risk to jumping into each
system. If you want to find a safe route between two systems, say Jita and Amarr, issue a get request to
`127.0.0.1:8008/safest-route/Amarr/to/Jita`
If you want to find a safe route between two systems, say Jita and Amarr, issue a get request to
`localhost:8008/safest-route/Amarr/to/Jita`.

## Ephemeral data

If it has been a while since you started the app, you should refresh wormhole connections by making a POST request to
`localhost:8008/wormholes/refresh`. These wormhole connections come from [EVE Scout](https://www.eve-scout.com/#/) and
are used in both the short and safe route path finding solutions below.
are used in both the short and safe route path finding solutions.

If you are using the safe routing feature, it is also good to regularly recompute (about every 30 minutes) the risk of
jumping into each system by making a POST request to `localhost:8008/systems/risk`.
12 changes: 10 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,22 @@ async fn main() {
.or(stargates_routes)
.recover(handle_rejection);

// Build or refresh all data
match synchronize_esi_systems(client.clone(), graph.clone()).await {
Ok(_) => {
// Stargate sync relies on systems being saved
match synchronize_esi_stargates(client.clone(), graph.clone()).await {
Ok(_) => {}
Ok(_) => {
// Jump risk sync relies on connections existing from stargate sync
refresh_jump_risks(client.clone(), graph.clone())
.await
.unwrap();
refresh_jump_risk_graph(graph.clone()).await.unwrap();
}
Err(err) => println!("Stargate synchronization failed {}", err),
}

refresh_eve_scout_system_relations(client, graph.clone())
refresh_eve_scout_system_relations(client.clone(), graph.clone())
.await
.unwrap();
refresh_jump_cost_graph(graph).await.unwrap();
Expand Down Expand Up @@ -486,6 +493,7 @@ async fn pull_last_hour_of_jumps(
}

async fn refresh_jump_risks(client: Client, graph: Arc<Graph>) -> Result<(), ReplicationError> {
println!("Refreshing system jump risks");
let galaxy_kills = pull_system_kills(client.clone(), graph.clone()).await?;
let galaxy_jumps = pull_last_hour_of_jumps(client.clone(), graph.clone()).await?;
let system_ids = get_all_system_ids(graph.clone()).await?;
Expand Down

0 comments on commit 7e061a9

Please sign in to comment.