-
Notifications
You must be signed in to change notification settings - Fork 3
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
Implemented travelTime Data Functionality #376
base: main
Are you sure you want to change the base?
Conversation
- Created travelTime collection - Implemented POST endpoint to calculate travel distances using Google Map Matrix API - Implemented testing POST endpoint to create single building document
[diff-counting] Significant lines: 531. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Early PR Review
Overall, this is a great start on this PR. For the code you have implemented so far, I have suggested some minor things you could do to make it better. I hope that the rest of your work on this PR will be of the same splendid quality :)
- Implemented travel documents document batch creation endpoint - Tested on smaller batches (size 10) - Created building travel time documents for all buildings
- Created endpoint for frontend travel time retrieval - Improved documentation for helper function
- Implemented frontend travel time display - Mofified ApartmentWithId type to include travelTimes attribute
- Modified TravelTimes type (isolated from Apartments type) - Implemented map recenter feature upon map modal closure - Implemented mobile map modal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job on this map backend PR! The map feature is definitely nearing completion and the travel time info will be very useful for users. I'm requesting changes for you to implement the small frontend change that David had mentioned (increasing the space between the location name and the map on the mobile modal) as well as adjusting the minimum font size of the location names in the mobile ver. of map modal to match the figma (13px, right now it's 10px and quite difficult to read on mobile) . Once the spacing and font size is fixed, you'll be fully finished with the map feature!
- Added spacing between address and map - Increased location and traveltime font size for better visibility
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Review
This is an excellent PR. Your implementation is responsive and correctly adapts the figma design. Your API endpoints seem mostly correct, however I suggested a few minor changes just to make sure it works when the API is not run locally. There are a couple of minor things you can do to further improve your code, such as fixing some documentation, so I've also suggested those changes with my comments :) Overall, great PR!
@@ -960,4 +964,269 @@ app.post('/api/add-contact-question', authenticate, async (req, res) => { | |||
} | |||
}); | |||
|
|||
interface TravelTimes { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you already imported LocationTravelTimes, you can delete TravelTimes and use the imported type.
} | ||
|
||
// Calculate travel times using the main endpoint | ||
const response = await axios.post(`http://localhost:3000/api/calculate-travel-times`, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can delete http://localhost:3000
from the axios post request. Keeping this part in the request means it will only work if you run the backend locally, but not on prod. I believe replacing it with axios.post('/api/calculate-travel-times')
may do the trick, but I didn't test this modification.
return; | ||
} | ||
|
||
const response = await axios.post(`http://localhost:3000/api/calculate-travel-times`, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, you can delete http://localhost:3000
from the axios post request.
* Looks up the travel times document for the given building ID and returns the stored walking and driving | ||
* times to Cornell landmarks: Engineering Quad, Agriculture Quad, and Ho Plaza. | ||
* | ||
* @route GET /api/travel-times/:buildingId |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adjust to /api/travel-times-by-id/:buildingId
@@ -150,6 +156,17 @@ const ApartmentPage = ({ user, setUser }: Props): ReactElement => { | |||
const saved = savedIcon; | |||
const unsaved = unsavedIcon; | |||
const [isSaved, setIsSaved] = useState(false); | |||
const mapInfoRef = useRef<MapInfoRef>(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remember to clean up unused variables! Just look at the check warnings from lint to see what is unused.
const Modals = landlordData && apt && ( | ||
<> | ||
<MapModal | ||
aptName={apt!.name} | ||
open={mapOpen} | ||
onClose={() => setMapOpen(false)} | ||
onClose={handleMapModalClose} | ||
setOpen={setMapOpen} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your setOpen parameter is no longer being used, so maybe remove setOpen as a parameter?
Summary
This pull request implements travel time data functionality for apartment pages, providing users with distance information from apartments to major campus locations.
Key implementations:
travelTimes
collection and corresponding data typesTest Plan
Backend Testing:
Frontend Testing:
map.auto-recenter.mov
Notes
Database Schema Changes:
travelTimes
API Integration:
Frontend Enhancements:
Breaking Changes
Database Updates:
travelTimes
collectionLocationTravelTimes
type in db-typesFuture Considerations