question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Project Admin - dashboard load fails

See original GitHub issue

Per chat w/ @xamanu @russdeffner - a few project admins are noticing a project loading error on the dashboard with 504 - Timeout error code.

Preliminary investigation shows this might be because of a nested loop situation.

This line here https://github.com/hotosm/tasking-manager/blob/develop/server/models/postgis/project.py#L348, which runs project summary for each project, is slowing down the process. Project summary has been updated in this recent release to do average time computations:

....

 "totalValidationTime": "22:47:45.990745",
  "totalTimeSpent": "11:33:46.122691",
  "averageMappingTime": "0:00:33.326294",
  "averageValidationTime": "0:08:17.363636",
  "status": "PUBLISHED"

Internally this fetches related tasks from the project table, iterates over the results and adds up time spent for each of the task. Now imagine this happening for 466 projects from @russdeffner - it is a loop within a loop

all projects for a user -> for each project:
    fetch tasks: ->  iterate over task list and add up time:

This is a classic case of a nested loop that increases the time complexity of a program (O(n²)). When an admin has more projects, this complexity is enhanced resulting in a timeout error.

How to solve?

  1. Remove time calculations from the project summary. Include time estimates in a different endpoint
  2. Retain time calculations within the project summary, but sum up time values from the column for validation & mapping. A limitation is the field type (varchar).
  3. Retain time calculation with project summary, add a centroid field to the project dto. Now for project fetch within the admin dashboard, invoke project dto function instead of the project summary function. Not able to tell immediately if this will impact other endpoints. But @russdeffner & I tried it briefly this evening and the frontend map rendering fails.

Next actions:

  • Try solution 2
  • If solution 2 fails, look at solution 1 (separate out time calculations)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
Vaomatuacommented, Jun 5, 2019

@ramyaragupathy Yes, the dashboard now loads in about 5 seconds for me. Thank you for fixing this.

0reactions
russdeffnercommented, Jun 6, 2019

Yep, works for me as well (on mobile).

On Jun 5, 2019, at 10:16 AM, Emmor notifications@github.com wrote:

@ramyaragupathy Yes, the dashboard now loads in about 5 seconds for me. Thank you for fixing this.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

Read more comments on GitHub >

github_iconTop Results From Across the Web

WordPress Admin Panel Dashboard not loading correctly
In this video you will see how to Fix WordPress Admin Panel Dashboard not loading properly in Wordpress WebsiteAdd this code ...
Read more >
WC 4.0 admin dashboard and images fail to load · Issue #25924
I set a default . htaccess and and clearing all browser caches - but still there were issues.
Read more >
Error message after integrating my admin panel dashboard in ...
1 Answer 1 · Verify that the template needed exists. As @omar-abdullah said, go to views/layouts/adminLayouts/ and verify that admin_header.
Read more >
Admin dashboard not loading - WordPress.org
I have to login on the front end via the Woocommerce login page and then use the top navigation bar to get to...
Read more >
How to Fix the "There Has Been a Critical Error on Your ...
Just log in to the hosting dashboard, then go to Sites > Tools > WordPress debugging and click Enable. You can then look...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found