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

[HOLD for payment 2023-10-12] [$500] [Distance] Web - Map and map image doesn't zoom out and display long unconventional routes #27175

Closed
2 of 6 tasks
kbecciv opened this issue Sep 11, 2023 · 34 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@kbecciv
Copy link

kbecciv commented Sep 11, 2023

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Action Performed:

. Open the app
2. Click on plus and click on request money
3. Click on 'Distance'
4. In start, select 'India' and in Finish, select 'Pakistan'
5. Observe that map does not display the whole route as it is not straightforward
6. Complete the process, open the request money message twice to open request money page
7. Click on map image to see that map does not display the route fully

Expected Result:

App should zoom out to display full route in map and image

Actual Result:

App does not zoom out to display full route in map and image for long distance unconventional routes

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: 1.3.67.2
Reproducible in staging?: y
Reproducible in production?: y
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation

doesnt.zoom.out.to.display.full.route.mp4
Recording.4391.mp4

Expensify/Expensify Issue URL:
Issue reported by: @dhanashree-sawant
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1694103719072409

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01c90939608885c398
  • Upwork Job ID: 1701278392102277120
  • Last Price Increase: 2023-09-11
  • Automatic offers:
    • mollfpr | Reviewer | 26914479
    • dhanashree-sawant | Reporter | 26914481
@kbecciv kbecciv added External Added to denote the issue can be worked on by a contributor Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Sep 11, 2023
@melvin-bot melvin-bot bot changed the title [Distance] Web - Map and map image doesn't zoom out and display long unconventional routes [$500] [Distance] Web - Map and map image doesn't zoom out and display long unconventional routes Sep 11, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 11, 2023

Job added to Upwork: https://www.upwork.com/jobs/~01c90939608885c398

@melvin-bot
Copy link

melvin-bot bot commented Sep 11, 2023

Triggered auto assignment to @maddylewis (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 11, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 11, 2023

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

@melvin-bot
Copy link

melvin-bot bot commented Sep 11, 2023

Triggered auto assignment to @kevinksullivan (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.

@melvin-bot
Copy link

melvin-bot bot commented Sep 11, 2023

Triggered auto assignment to Contributor-plus team member for initial proposal review - @mollfpr (External)

@sumairq
Copy link

sumairq commented Sep 11, 2023

Proposed solution

Please re-state the problem that we are trying to solve in this issue.

Assign Task - Web - Map and map image doesn't zoom out and display long unconventional routes

What is the root cause of that problem?**

getBounds function in the utils for mapbox does not add buffer zone around the calculated bounds and does not calculate a zoom level that comfortably fits the entire route within the map's view.

What changes do you think we should make in order to solve the problem?**

  • Add a buffer zone around the calculated bounds. This will ensure that the route is not displayed right at the map's edge, leaving some margin for better visibility.
  • Calculate the zoom level based on the distance between the north-east and south-west coordinates. This will all us to set a zoom level that comfortably fits the entire route within the map's view.
  • Calculate the center of the bounding box, which will be used as the map's new center after zooming.
    function getBounds(waypoints: Array<[number, number]>): {southWest: [number, number]; northEast: [number, number]} {
    const lngs = waypoints.map((waypoint) => waypoint[0]);
    const lats = waypoints.map((waypoint) => waypoint[1]);
    return {
    southWest: [Math.min(...lngs), Math.min(...lats)],
    northEast: [Math.max(...lngs), Math.max(...lats)],
    };
    }
    export default {
    getBounds,
    };

Following calculations can be added in the getBounds() utility function.

  const center = [
        (northEast[0] + southWest[0]) / 2,
        (northEast[1] + southWest[1]) / 2,
    ];

    // Calculates the distance between the north-east and south-west coordinates
    const distanceLng = northEast[0] - southWest[0];
    const distanceLat = northEast[1] - southWest[1];

    // Calculates the zoom level based on the bounding box dimensions and buffer
    const zoomLng = Math.log2((360 / distanceLng) * (1 + bufferFactor));
    const zoomLat = Math.log2((180 / distanceLat) * (1 + bufferFactor));
    const zoom = Math.min(zoomLng, zoomLat);

What alternative solutions did you explore? (Optional)

none

@mollfpr
Copy link
Contributor

mollfpr commented Sep 15, 2023

@sumairq Are you suggesting to add the zoomLevel props to the map? What the center variable will do?

Also, could you attach a video of the working result?

@rakshitjain13
Copy link
Contributor

rakshitjain13 commented Sep 16, 2023

Proposal

Please re-state the problem that we are trying to solve in this issue.

App should zoom out to display full route in map and image

What is the root cause of that problem?

Currently, to find the bounds of the map we are using only waypoints (start, end, stop points). This can be seen in the below code block to get bounds.

function getBounds(waypoints: Array<[number, number]>): {southWest: [number, number]; northEast: [number, number]} {
const lngs = waypoints.map((waypoint) => waypoint[0]);
const lats = waypoints.map((waypoint) => waypoint[1]);
return {
southWest: [Math.min(...lngs), Math.min(...lats)],
northEast: [Math.max(...lngs), Math.max(...lats)],
};
}
export default {
getBounds,
};

What changes do you think we should make in order to solve the problem?

We should also consider direction Points in getting the bounds of the map like below :

function getBounds(waypoints: Array<[number, number]>, directionCoordinates: undefined | [number, number][]): {southWest: [number, number]; northEast: [number, number]} {
    const lngs = waypoints.map((waypoint) => waypoint[0]);
    const lats = waypoints.map((waypoint) => waypoint[1]);
    if (directionCoordinates) {
        lngs.push(...directionCoordinates.map((coordinate) => coordinate[0]));
        lats.push(...directionCoordinates.map((coordinate) => coordinate[1]));
    }

    return {
        southWest: [Math.min(...lngs), Math.min(...lats)],
        northEast: [Math.max(...lngs), Math.max(...lats)],
    };
}

export default {
    getBounds,
};

Attaching a video for support :

Expnsify.mov

We need to also change the backend that generates a static map preview that is visible in report.

What alternative solutions did you explore? (Optional)

NA

@rakshitjain13
Copy link
Contributor

Proposal

Updated(#27175 (comment))

@melvin-bot melvin-bot bot added the Overdue label Sep 18, 2023
@mollfpr
Copy link
Contributor

mollfpr commented Sep 18, 2023

@rakshitjain13 Where do we get the value of directionCoordinates ?

@melvin-bot melvin-bot bot removed the Overdue label Sep 18, 2023
@rakshitjain13
Copy link
Contributor

rakshitjain13 commented Sep 18, 2023

@mollfpr In MapView Component src/components/MapView/MapView.web.tsx directionCoordinates are passed as props and thus we will pass this variable in below function

const {northEast, southWest} = utils.getBounds(waypoints.map((waypoint) => waypoint.coordinate));

Same thing goes to src/components/MapView/MapView.tsx

@mollfpr
Copy link
Contributor

mollfpr commented Sep 18, 2023

Thanks @rakshitjain13!

The proposal from @rakshitjain13 looks good to me! It also makes sense to consider the direction coor to show the full map.

🎀 👀 🎀 C+ reviewed!

@melvin-bot
Copy link

melvin-bot bot commented Sep 18, 2023

Triggered auto assignment to @chiragsalian, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@maddylewis maddylewis added Weekly KSv2 and removed Daily KSv2 labels Sep 18, 2023
@rakshitjain13
Copy link
Contributor

@chiragsalian When can I expect the offer on my upwork so that I can raise PR ASAP

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Weekly KSv2 labels Sep 28, 2023
@rakshitjain13
Copy link
Contributor

@mollfpr Updated the PR as per requested #28416

@melvin-bot
Copy link

melvin-bot bot commented Oct 2, 2023

🎯 ⚡️ Woah @mollfpr / @rakshitjain13, great job pushing this forwards! ⚡️

The pull request got merged within 3 working days of assignment, so this job is eligible for a 50% #urgency bonus 🎉

  • when @rakshitjain13 got assigned: 2023-09-27 23:22:21 Z
  • when the PR got merged: 2023-10-02 17:09:07 UTC

On to the next one 🚀

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Oct 5, 2023
@melvin-bot melvin-bot bot changed the title [$500] [Distance] Web - Map and map image doesn't zoom out and display long unconventional routes [HOLD for payment 2023-10-12] [$500] [Distance] Web - Map and map image doesn't zoom out and display long unconventional routes Oct 5, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Oct 5, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 5, 2023

Reviewing label has been removed, please complete the "BugZero Checklist".

@melvin-bot
Copy link

melvin-bot bot commented Oct 5, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.77-7 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2023-10-12. 🎊

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

For reference, here are some details about the assignees on this issue:

As a reminder, here are the bonuses/penalties that should be applied for any External issue:

  • Merged PR within 3 business days of assignment - 50% bonus
  • Merged PR more than 9 business days after assignment - 50% penalty

@melvin-bot
Copy link

melvin-bot bot commented Oct 5, 2023

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@mollfpr] The PR that introduced the bug has been identified. Link to the PR:
  • [@mollfpr] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • [@mollfpr] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
  • [@mollfpr] Determine if we should create a regression test for this bug.
  • [@mollfpr] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@maddylewis] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Daily KSv2 Overdue and removed Weekly KSv2 labels Oct 11, 2023
@maddylewis
Copy link
Contributor

maddylewis commented Oct 13, 2023

Payments

#27175 (comment)

@melvin-bot melvin-bot bot removed the Overdue label Oct 13, 2023
@maddylewis
Copy link
Contributor

@mollfpr - can you review this checklist - thanks! #27175 (comment)

@rakshitjain13
Copy link
Contributor

rakshitjain13 commented Oct 13, 2023

@maddylewis I didn't receive any offer on upwork as it was my first PR. Let me know if I am missing something.

@maddylewis
Copy link
Contributor

@rakshitjain13 - yep, i updated the price already. and then will you follow the instructions outlined in this comment and apply to the job on Upwork? leave a comment here once you've done that and i will process the payment. thanks!

#27175 (comment)

@rakshitjain13
Copy link
Contributor

@maddylewis Already applied to the Upwork job with my Upwork ID: https://www.upwork.com/freelancers/~01c427caaa5ebf3b9c

@maddylewis
Copy link
Contributor

payments sent / just waiting on BZ checklist to be reviewed before closing.

@mollfpr mollfpr mentioned this issue Oct 15, 2023
59 tasks
@mollfpr
Copy link
Contributor

mollfpr commented Oct 15, 2023

[@mollfpr] The PR that introduced the bug has been identified. Link to the PR:

#26500

[@mollfpr] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:

https://github.com/Expensify/App/pull/26500/files#r1359918071

[@mollfpr] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:

The regressions step should be enough.

[@mollfpr] Determine if we should create a regression test for this bug.
[@mollfpr] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.

  1. Click on the green + icon button
  2. Click on Request Money
  3. Select Distance Tab
  4. In the start point type India
  5. In stop point type Pakistan
  6. Verify that the whole route is showing on the map
  7. 👍 or 👎

@JmillsExpensify
Copy link

$1000 payment approved for @mollfpr based on BZ summary.

@melvin-bot melvin-bot bot added the Overdue label Oct 17, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 19, 2023

@chiragsalian, @mollfpr, @maddylewis, @rakshitjain13 Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@melvin-bot melvin-bot bot removed the Overdue label Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

8 participants