Page MenuHomeSoftware Heritage

templates/homepage: Fix counters display when storage is empty
ClosedPublic

Authored by anlambert on Mar 27 2020, 4:11 PM.

Details

Summary

This is a simple fix for the counters display in the webapp homepage.

When the storage is empty (for instance after booting the docker env), the
/api/1/stat/counters endpoint returns an empty dict.

So handle that corner case to avoid a JavaScript error when homepage is loading.

Diff Detail

Repository
rDWAPPS Web applications
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

anlambert created this revision.Mar 27 2020, 4:11 PM
vlorentz requested changes to this revision.Mar 27 2020, 5:07 PM
vlorentz added a subscriber: vlorentz.

Could you add a test for this? (eg. using Cypress to mock calls to the counter API)

This revision now requires changes to proceed.Mar 27 2020, 5:07 PM
anlambert updated this revision to Diff 10380.Mar 30 2020, 2:35 PM

Update: Add cypress test

Build has FAILED

Patch application report for D2913 (id=10380)

Rebasing onto d4446bcac7...

Current branch diff-target is up to date.
Changes applied before test
commit e0e2f4f7ea0ca54770b6fc0fa99bfb378c520c63
Author: Antoine Lambert <antoine.lambert@inria.fr>
Date:   Fri Mar 27 15:02:44 2020 +0100

    templates/homepage: Fix counters display when storage is empty

Link to build: https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/11/
See console output for more information: https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/11/console

Build is green

Patch application report for D2913 (id=10380)

Rebasing onto d4446bcac7...

Current branch diff-target is up to date.
Changes applied before test
commit e0e2f4f7ea0ca54770b6fc0fa99bfb378c520c63
Author: Antoine Lambert <antoine.lambert@inria.fr>
Date:   Fri Mar 27 15:02:44 2020 +0100

    templates/homepage: Fix counters display when storage is empty

See https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/12/ for more details.

Build is green

Patch application report for D2913 (id=10380)

Rebasing onto d4446bcac7...

Current branch diff-target is up to date.
Changes applied before test
commit e0e2f4f7ea0ca54770b6fc0fa99bfb378c520c63
Author: Antoine Lambert <antoine.lambert@inria.fr>
Date:   Fri Mar 27 15:02:44 2020 +0100

    templates/homepage: Fix counters display when storage is empty

See https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/15/ for more details.

vlorentz accepted this revision.Mar 31 2020, 10:11 AM
This revision is now accepted and ready to land.Mar 31 2020, 10:11 AM

Build is green

Patch application report for D2913 (id=10407)

Rebasing onto 9aa7f44e81...

Current branch diff-target is up to date.
Changes applied before test
commit f8ac17e10778b028aa794a4a4a1935e857d46406
Author: Antoine Lambert <antoine.lambert@inria.fr>
Date:   Fri Mar 27 15:02:44 2020 +0100

    templates/homepage: Fix counters display when storage is empty

See https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/22/ for more details.