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

Adding client side report generation #146

Open
wants to merge 15 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 14 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
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"keyfile",
"ksession",
"loadercss",
"ldot",
Copy link
Collaborator

@payneBrandon payneBrandon Mar 5, 2025

Choose a reason for hiding this comment

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

question(non-blocking): what is ldot?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

lane direction of travel. This was used in variables like "ldotReportData"

"LOGLEVEL",
"luxon",
"masterdiv",
Expand Down
2 changes: 1 addition & 1 deletion services/intersection-api/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Install and run the intersection API using the following commands:
2. **Run the application with the `dev` profile**:

```sh
mvn -Dspring-boot.run.profiles=dev spring-boot:run
mvn -Dspring-boot:run.profiles=dev spring-boot:run
```

## Running Tests
Expand Down
163 changes: 162 additions & 1 deletion webapp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@
"fbjs": "^3.0.4",
"file-saver": "^2.0.5",
"formik": "^2.4.6",
"html-to-image": "^1.11.11",
"isomorphic-fetch": "^3.0.0",
"jest-fetch-mock": "^3.0.3",
"jspdf": "^2.5.2",
"jszip": "^3.10.1",
"keycloak-js": "21.1.1",
"luxon": "^3.5.0",
Expand Down
61 changes: 59 additions & 2 deletions webapp/src/apis/intersections/reports-api.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import {
LaneDirectionOfTravelReportData,
StopLinePassageReportData,
StopLineStopReportData,
} from '../../models/ReportData'
import { authApiHelper } from './api-helper-cviz'

export type ReportMetadata = {
Expand All @@ -8,6 +13,38 @@ export type ReportMetadata = {
reportStartTime: Date
reportStopTime: Date
reportContents: string[]
laneDirectionOfTravelEventCounts: CountWithId[]
laneDirectionOfTravelMedianDistanceDistribution: CountWithId[]
laneDirectionOfTravelMedianHeadingDistribution: CountWithId[]
laneDirectionOfTravelReportData: LaneDirectionOfTravelReportData[]
connectionOfTravelEventCounts: CountWithId[]
signalStateConflictEventCount: CountWithId[]
signalStateEventCounts: CountWithId[]
signalStateStopEventCounts: CountWithId[]
timeChangeDetailsEventCount: CountWithId[]
intersectionReferenceAlignmentEventCounts: CountWithId[]
mapBroadcastRateEventCount: CountWithId[]
mapMinimumDataEventCount: CountWithId[]
spatMinimumDataEventCount: CountWithId[]
spatBroadcastRateEventCount: CountWithId[]
latestMapMinimumDataEventMissingElements: string[]
latestSpatMinimumDataEventMissingElements: string[]
validConnectionOfTravelData: {
connectionID: number
ingressLaneID: number
egressLaneID: number
eventCount: number
}[]
invalidConnectionOfTravelData: {
connectionID: number
ingressLaneID: number
egressLaneID: number
eventCount: number
}[]
headingTolerance: number
distanceTolerance: number
stopLineStopReportData: StopLineStopReportData[]
stopLinePassageReportData: StopLinePassageReportData[]
}

class ReportsApi {
Expand All @@ -29,8 +66,17 @@ class ReportsApi {
const queryParams: Record<string, string> = {}
queryParams['intersection_id'] = intersectionId.toString()
queryParams['road_regulator_id'] = roadRegulatorId.toString()
if (startTime) queryParams['start_time_utc_millis'] = startTime.getTime().toString()
if (endTime) queryParams['end_time_utc_millis'] = endTime.getTime().toString()

if (startTime) {
const startTimeUTC = new Date(startTime.getTime() - startTime.getTimezoneOffset() * 60000)
startTimeUTC.setSeconds(0, 0)
queryParams['start_time_utc_millis'] = startTimeUTC.getTime().toString()
}
if (endTime) {
const endTimeUTC = new Date(endTime.getTime() - endTime.getTimezoneOffset() * 60000)
endTimeUTC.setSeconds(0, 0)
queryParams['end_time_utc_millis'] = endTimeUTC.getTime().toString()
}

const pdfReport = await authApiHelper.invokeApi({
path: `/reports/generate`,
Expand Down Expand Up @@ -76,6 +122,17 @@ class ReportsApi {
tag: 'intersection',
})

if (pdfReport) {
pdfReport.forEach((report: ReportMetadata) => {
report.reportStartTime = new Date(
new Date(report.reportStartTime).getTime() + new Date(report.reportStartTime).getTimezoneOffset() * 60000
)
report.reportStopTime = new Date(
new Date(report.reportStopTime).getTime() + new Date(report.reportStopTime).getTimezoneOffset() * 60000
)
})
}

return pdfReport
}

Expand Down
Loading
Loading