forked from motis-project/motis
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add validity array building * feat: add plan comparation, css adjustments * feat: add mismatched default plan
- Loading branch information
Showing
10 changed files
with
23,041 additions
and
358 deletions.
There are no files selected for viewing
22,367 changes: 22,367 additions & 0 deletions
22,367
visual-debugger/src/data-processing/assets/default-plan-mismatched.json
Large diffs are not rendered by default.
Oops, something went wrong.
643 changes: 427 additions & 216 deletions
643
visual-debugger/src/data-processing/assets/default-plan.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import type {Plan} from "./parsing-types/planParsingTypes.ts"; | ||
import { | ||
currentDefaultPlanStore, | ||
currentPlanStore, | ||
defaultPlanDatasetStore, | ||
planDatasetStore | ||
} from "../sveltestore.ts"; | ||
import {cssClasses} from "./parsing-types/cssClasses.ts"; | ||
import {resetCssClassesForPlanEntries} from "./planParsing.ts"; | ||
|
||
/** | ||
* Compares the computed results of the queries with the uploaded default plan and sets colors of the matches/mismatches | ||
*/ | ||
export function comparePlans() { | ||
let plans: Plan[] = []; | ||
let defaultPlans: Plan[] = []; | ||
|
||
planDatasetStore.subscribe(data => { | ||
plans = data | ||
}) | ||
|
||
defaultPlanDatasetStore.subscribe(data => { | ||
defaultPlans = data | ||
}) | ||
|
||
//reset css classes | ||
for (let i = 0; i < plans.length; i++) { | ||
resetCssClassesForPlanEntries(plans[i]); | ||
resetCssClassesForPlanEntries(defaultPlans[i]); | ||
} | ||
|
||
// find if one plan has more entries than the other | ||
if (plans.length != defaultPlans.length) { | ||
if (plans.length >= defaultPlans.length) { | ||
alert("Error: There are more queries in the batch than in the default plans.") | ||
return | ||
} else { | ||
alert("Error: There are more queries in the default plan than in the batch.") | ||
return | ||
} | ||
} | ||
|
||
// iterate over all plans | ||
for (let planIndex = 0; planIndex < plans.length; planIndex++) { | ||
|
||
let currentPlan: Plan = plans[planIndex]; | ||
let currentDefaultPlan: Plan = defaultPlans[planIndex]; | ||
|
||
// iterate over all itineraries of a plan | ||
for (let itineraryIndex = 0; itineraryIndex < currentPlan.itineraries.length; itineraryIndex++) { | ||
|
||
let currentItinerary = currentPlan.itineraries[itineraryIndex]; | ||
let currentDefaultItinerary = currentDefaultPlan.itineraries[itineraryIndex]; | ||
|
||
// compare strings of itineraries and set colors(CSS-Classes) accordingly | ||
if (JSON.stringify(currentItinerary) == JSON.stringify(currentDefaultItinerary)) { | ||
// itineraries are equal, mark them as such | ||
plans[planIndex].itineraries[itineraryIndex].cssClass = new cssClasses().planEntryValid | ||
defaultPlans[planIndex].itineraries[itineraryIndex].cssClass = new cssClasses().planEntryValid | ||
|
||
} else { | ||
// itineraries are not equal | ||
plans[planIndex].itineraries[itineraryIndex].cssClass = new cssClasses().planEntryInvalid | ||
defaultPlans[planIndex].itineraries[itineraryIndex].cssClass = new cssClasses().planEntryInvalid | ||
} | ||
|
||
} | ||
|
||
// update the current stores to show the matches/mismatches | ||
currentPlanStore.set(plans[0]) | ||
currentDefaultPlanStore.set(defaultPlans[0]) | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
visual-debugger/src/data-processing/parsing-types/cssClasses.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** | ||
* | ||
*/ | ||
export class cssClasses{ | ||
planEntryValid: string = "w-full my-2 border-green-500 bg-green-200" | ||
|
||
planEntryInvalid: string = "w-full my-2 border-red-500 bg-red-200" | ||
|
||
planEntryDefault: string = "w-full my-2 border-white-500 bg-white-200" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.