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

Use mock data for homepage charts to reduce startup loading time #10179

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

schu96
Copy link
Contributor

@schu96 schu96 commented Dec 22, 2024

Closes #10118

Fix

Technical

Checks if the current running instance is a dev environment using web.ctx.features and utilizes mock data to display the charts on the front page. Minor CSS styling issue fix for chart labels.

Testing

  1. Run docker compose up -d
  2. Open your browser's developer tools and select the Network tab before navigating to localhost:8080
  3. Check how long it takes for the homepage to completely load
    • My local instance loading time dropped from roughly ~22 seconds to ~2 seconds, timings for other machines and browsers will most likely vary

Screenshot

Before

image
After

image

Stakeholders

@jimchamp @RayBB

@github-actions github-actions bot added the Priority: 2 Important, as time permits. [managed] label Dec 22, 2024
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 17.44%. Comparing base (3025f5d) to head (1653a91).
Report is 33 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #10179   +/-   ##
=======================================
  Coverage   17.44%   17.44%           
=======================================
  Files          89       89           
  Lines        4792     4792           
  Branches      848      848           
=======================================
  Hits          836      836           
  Misses       3436     3436           
  Partials      520      520           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@RayBB
Copy link
Collaborator

RayBB commented Dec 22, 2024

We're you able to time how much faster the home page is ready?

@schu96
Copy link
Contributor Author

schu96 commented Dec 22, 2024

We're you able to time how much faster the home page is ready?

Not sure if this was the best method to use but I used the Firefox Networking tab to get the request duration for the homepage which I included in the screenshots (23 seconds to 2 seconds)

Copy link
Collaborator

@RayBB RayBB left a comment

Choose a reason for hiding this comment

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

This is great work! What a huge improvement for development environments :)

@jimchamp is the lead so he'll provide the final feedback.

However, I'll give one piece of feedback.

I think the convention of the codebase is to set something up in dev_instance.py for the mock data. I'm not exactly sure how it should work in this case with overriding data/function but it would likely simplify the PR a decent amount. It could be as simple as adding admin._get_count_docs = admin.mock_get_stats.

Even if you choose not to go this approach the get_stats function could probably be simplified by having one return statement and the if/else just about setting the docs variable.

Anyway, good work and I hope Jim can review soon :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: 2 Important, as time permits. [managed]
Projects
Status: Waiting Review/Merge from Staff
Development

Successfully merging this pull request may close these issues.

Fix startup time for local development environment
4 participants