Description:
Currently, our occupation logic for parking spots does not keep track of their history. We need to implement a feature that allows us to save the parking history of a certain spot. This will enable us to track the number of cars that visited the spot in a session, calculate the percentage of time it was occupied, and determine the average parking duration.
Proposed Solution:
To implement the parking history functionality, we can introduce the following changes:
Create a data structure to store the history of each parking spot. This can be achieved by using a list or an array of objects, where each object represents a session.
Each object in the history list will contain the necessary information, including the number of cars that visited the spot in that session and the parking duration for each car.
Update the occupation logic to record the history of a parking spot. When a car leaves the spot, the current session's data (number of cars and their duration's) should be added to the history list.
To calculate the percentage of time the spot was occupied, iterate over the history list and sum up the duration's of all sessions. Divide this sum by the total available time to get the occupancy percentage.
To determine the average parking duration, iterate over the history list and calculate the average duration per session.
Additional Considerations:
Ensure that the parking history is stored persistently, either in a database or a file, so that it is not lost when the system restarts.
Provide a way to access and display the parking history information, such as through a reporting feature or an API endpoint.
Acceptance Criteria:
The occupation logic should be updated to record the parking history of each spot.
The history should include the number of cars that visited the spot in a session and the parking duration for each car.
The percentage of time the spot was occupied should be calculated correctly.
The average parking duration should be calculated accurately.
The parking history should be stored persistently and accessible for reporting purposes.
Description: Currently, our occupation logic for parking spots does not keep track of their history. We need to implement a feature that allows us to save the parking history of a certain spot. This will enable us to track the number of cars that visited the spot in a session, calculate the percentage of time it was occupied, and determine the average parking duration.
Proposed Solution: To implement the parking history functionality, we can introduce the following changes:
Create a data structure to store the history of each parking spot. This can be achieved by using a list or an array of objects, where each object represents a session.
Each object in the history list will contain the necessary information, including the number of cars that visited the spot in that session and the parking duration for each car.
Update the occupation logic to record the history of a parking spot. When a car leaves the spot, the current session's data (number of cars and their duration's) should be added to the history list.
To calculate the percentage of time the spot was occupied, iterate over the history list and sum up the duration's of all sessions. Divide this sum by the total available time to get the occupancy percentage.
To determine the average parking duration, iterate over the history list and calculate the average duration per session.
Additional Considerations:
Ensure that the parking history is stored persistently, either in a database or a file, so that it is not lost when the system restarts. Provide a way to access and display the parking history information, such as through a reporting feature or an API endpoint. Acceptance Criteria:
The occupation logic should be updated to record the parking history of each spot. The history should include the number of cars that visited the spot in a session and the parking duration for each car. The percentage of time the spot was occupied should be calculated correctly. The average parking duration should be calculated accurately. The parking history should be stored persistently and accessible for reporting purposes.