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

Simplify media FetchState and fix fetching errors #5323

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

obulat
Copy link
Contributor

@obulat obulat commented Jan 8, 2025

Fixes

Fixes #5322
Fixes #5325

Description

This PR replaces the flags used in FetchState with single status property, and an additional error property. To prevent invalid states where status is not error, but there's error, the type uses TypeScript discriminated union.

Some other changes:

  • getters for the derived states added or updated in the media store to decide:
    • whether to show the load more button
    • whether to show the result count or "Loading" in the results labels
  • fetchMedia returns the Results type that is a discriminated union (so, the type property determines the type of the items in the items list)

Testing instructions

Run the app using ov just frontend/run dev
Search for "bamberg" and try the steps in #5325 - the errors from the issue should be fixed.
Fetching the media should work properly, both in the client and in SSR.
When the first page of results is loading on All media content, the content links should not say "No results", but should show "Loading..." label instead.


I tried creating a PR completely using the GitHub copilot, but I had to add a lot of changes on the first version: Copilot Workspace session.

@obulat obulat requested a review from a team as a code owner January 8, 2025 10:22
@obulat obulat requested review from krysal and dhruvkb January 8, 2025 10:22
@obulat obulat marked this pull request as draft January 8, 2025 10:22
@openverse-bot openverse-bot added 🧱 stack: frontend Related to the Nuxt frontend 🟨 priority: medium Not blocking but should be addressed soon 🧰 goal: internal improvement Improvement that benefits maintainers, not users 💻 aspect: code Concerns the software code in the repository labels Jan 8, 2025
@obulat obulat force-pushed the obulat/refactor-fetchstate branch 2 times, most recently from b31b1f9 to af9a134 Compare January 8, 2025 18:37
Copy link

github-actions bot commented Jan 8, 2025

Latest k6 run output1

     ✓ status was 200

     checks.........................: 100.00% ✓ 404      ✗ 0   
     data_received..................: 99 MB   412 kB/s
     data_sent......................: 53 kB   220 B/s
     http_req_blocked...............: avg=32.17µs  min=2.32µs   med=4.53µs   max=306.84µs p(90)=144.08µs p(95)=157.63µs
     http_req_connecting............: avg=19.67µs  min=0s       med=0s       max=245.3µs  p(90)=95.68µs  p(95)=109.76µs
     http_req_duration..............: avg=160.72ms min=17.71ms  med=116.02ms max=986.21ms p(90)=340.7ms  p(95)=443.48ms
       { expected_response:true }...: avg=160.72ms min=17.71ms  med=116.02ms max=986.21ms p(90)=340.7ms  p(95)=443.48ms
   ✓ http_req_failed................: 0.00%   ✓ 0        ✗ 404 
     http_req_receiving.............: avg=157.4µs  min=55.54µs  med=129.92µs max=552.57µs p(90)=263.71µs p(95)=307.29µs
     http_req_sending...............: avg=23.71µs  min=8.02µs   med=22.19µs  max=59.83µs  p(90)=34.21µs  p(95)=41.42µs 
     http_req_tls_handshaking.......: avg=0s       min=0s       med=0s       max=0s       p(90)=0s       p(95)=0s      
     http_req_waiting...............: avg=160.54ms min=17.6ms   med=115.79ms max=985.98ms p(90)=340.4ms  p(95)=443.15ms
     http_reqs......................: 404     1.677691/s
     iteration_duration.............: avg=849.67ms min=359.31ms med=925.45ms max=1.66s    p(90)=1.12s    p(95)=1.38s   
     iterations.....................: 77      0.319758/s
     vus............................: 2       min=0      max=6 
     vus_max........................: 60      min=60     max=60

Footnotes

  1. This comment will automatically update with new output each time k6 runs for this PR

@obulat obulat force-pushed the obulat/refactor-fetchstate branch 2 times, most recently from fda6fbe to 467d6e1 Compare January 9, 2025 05:11
@obulat obulat force-pushed the obulat/refactor-fetchstate branch from 467d6e1 to aa359a0 Compare January 9, 2025 07:35
@obulat obulat changed the title Refactor FetchState to use discriminated union Simplify media FetchState and fix fetching errors Jan 9, 2025
Copy link

github-actions bot commented Jan 9, 2025

Playwright failure test results: https://github.com/WordPress/openverse/actions/runs/12688482927

It looks like some of the Playwright tests failed. If you made changes to the frontend UI without updating snapshots, this might be the cause. You can download zipped patches containing the updated snapshots alongside a general trace of the tests under the "Artifacts" section in the above page. They're named in the form *_snapshot_diff and *_test_results respectively.

You can read more on how to use these artifacts in the docs.

If the test is flaky, follow the flaky test triage procedure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💻 aspect: code Concerns the software code in the repository 🧰 goal: internal improvement Improvement that benefits maintainers, not users 🟨 priority: medium Not blocking but should be addressed soon 🧱 stack: frontend Related to the Nuxt frontend
Projects
Status: 🚧 Draft
2 participants