Skip to content

Commit

Permalink
Merge pull request #211 from TurtIeSocks/route-export-fixes
Browse files Browse the repository at this point in the history
fix: route export dialog
  • Loading branch information
TurtIeSocks authored Dec 4, 2023
2 parents 44b15dd + 7b9c617 commit 50c5561
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 17 deletions.
4 changes: 1 addition & 3 deletions client/src/components/dialogs/ImportExport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ export function ImportExportDialog({
<DialogHeader action={reset}>
{mode} {shape}
</DialogHeader>
<DialogContent
sx={{ width: '90vw', minHeight: '60vh', overflow: 'auto' }}
>
<DialogContent>
<Grid2 container>
<Grid2 xs={children ? 9 : 12} textAlign="left">
<Code
Expand Down
23 changes: 15 additions & 8 deletions client/src/components/dialogs/Route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,25 @@ function BaseDialog({

return (
<ImportExportDialog mode={mode} shape="Route" open={open}>
<Grid2 xs={3} container justifyContent="flex-start">
<Grid2
xs={3}
container
justifyContent="flex-start"
maxHeight="70vh"
overflow="auto"
>
{[
{ label: 'Count', value: stats.count },
{ label: 'Max', value: stats.max?.toFixed(2) },
{ label: 'Max', value: stats.max?.toFixed(2), endAdornment: 'm' },
{
label: 'Average',
value: (stats.total / (stats.count || 1))?.toFixed(2),
endAdornment: 'm',
},
{
label: 'Total',
label: 'Total Distance',
value: stats.total?.toFixed(2),
endAdornment: 'm',
},
{
label: 'Covered',
Expand All @@ -37,16 +45,15 @@ function BaseDialog({
label: 'Score',
value: stats.score,
},
].map(({ label, value }) => (
].map(({ label, value, endAdornment }) => (
<Grid2 key={label} xs={12}>
<TextField
size="small"
value={value || 0}
label={label}
sx={{ width: '90%', my: 2 }}
sx={{ width: '80%', my: 2 }}
disabled
InputProps={{
endAdornment: label === 'Average' || label === 'Max' ? 'm' : '',
}}
InputProps={{ endAdornment }}
/>
</Grid2>
))}
Expand Down
17 changes: 11 additions & 6 deletions server/api/src/public/v1/calculate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,14 +353,17 @@ async fn route_stats(payload: web::Json<Args>) -> Result<HttpResponse, Error> {
..
} = payload.into_inner().init(Some("route-stats"));

if clusters.is_empty() || data_points.is_empty() {
if clusters.is_empty() && data_points.is_empty() {
return Ok(HttpResponse::BadRequest()
.json(Response::send_error("no_clusters_or_data_points_found")));
}
let mut stats = Stats::new(format!("Route Stats | {:?}", mode), min_points);
stats.cluster_stats(radius, &data_points, &clusters);

stats.distance_stats(&clusters);
stats.set_score();
if !data_points.is_empty() {
stats.cluster_stats(radius, &data_points, &clusters);
stats.set_score();
}

let feature = clusters.to_feature(Some(mode.clone())).remove_last_coord();
let feature = feature.to_collection(Some(instance.clone()), Some(mode));
Expand Down Expand Up @@ -408,16 +411,18 @@ async fn route_stats_category(
.to_single_vec()
};

if clusters.is_empty() || data_points.is_empty() {
if clusters.is_empty() && data_points.is_empty() {
return Ok(HttpResponse::BadRequest()
.json(Response::send_error("no_clusters_or_data_points_found")));
}

let mut stats = Stats::new(format!("Route Stats | {:?}", mode), min_points);

stats.cluster_stats(radius, &data_points, &clusters);
stats.distance_stats(&clusters);
stats.set_score();
if !data_points.is_empty() {
stats.cluster_stats(radius, &data_points, &clusters);
stats.set_score();
}

let feature = clusters.to_feature(Some(mode.clone())).remove_last_coord();
let feature = feature.to_collection(Some(instance.clone()), Some(mode));
Expand Down

1 comment on commit 50c5561

@vercel
Copy link

@vercel vercel bot commented on 50c5561 Dec 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

koji – ./

koji-turtiesocks.vercel.app
koji.vercel.app
koji-git-main-turtiesocks.vercel.app

Please sign in to comment.