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

Crash de hugo quand une colonne ou un critère est conforme #5

Open
bamthomas opened this issue Nov 28, 2023 · 3 comments
Open

Crash de hugo quand une colonne ou un critère est conforme #5

bamthomas opened this issue Nov 28, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@bamthomas
Copy link
Contributor

bamthomas commented Nov 28, 2023

Lorsqu'on met tout un critère conforme, l'application plante.

Reproduction :

Par exemple mettre tout le critère 12 (qui n'a que 3 tests) à conforme

image

Alors on obtient l'erreur suivante :

Error: error building site: render: failed to render pages: render of "home" failed: "/home/dev/src/audits-frago/themes/frago/layouts/index.html:34:23": execute of template failed: template: index.html:34:23: executing "main" at <partialCached "templates/projects-list.html" . .>: error calling partialCached: "/home/dev/src/audits-frago/themes/frago/layouts/partials/templates/projects-list.html:4:35": execute of template failed: template: partials/templates/projects-list.html:4:35: executing "partials/templates/projects-list.html" at <partialCached "render/aggregate-scores.html" (dict "pages" ($.Store.Get "rangepages")) ($.Store.Get "rangepages")>: error calling partialCached: "/home/dev/src/audits-frago/themes/frago/layouts/partials/render/aggregate-scores.html:181:29": execute of template failed: template: partials/render/aggregate-scores.html:181:29: executing "partials/render/aggregate-scores.html" at <merge (merge ($data.Get (printf "average-%s-conforme-t" $type)) ($data.Get (printf "average-%s-nonconforme-t" $type))) ($data.Get (printf "average-%s-nonapplicable-t" $type))>: error calling merge: destination must be a map, got <nil>

Ou encore à l'écran :

image

Obstacle pour terminer #3

@bamthomas bamthomas added the bug Something isn't working label Nov 28, 2023
@bamthomas
Copy link
Contributor Author

bamthomas commented Nov 28, 2023

il semble que, quand aucun critère/page n'est conforme, on ne rentre pas dans la condition de la ligne 179

{{ if and ($data.Get (printf "average-%s-conforme-t" $type)) ($data.Get (printf "average-%s-nonconforme-t" $type)) }}

Mais quand on y rentre, le test vérifie les tableaux conforme/nonconforme qui sont renseignés mais dans notre cas celui nonapplicable est vide, ce qui cause l'erreur sur le merge de la ligne d'après :

{{ range $id, $value := (merge (merge ($data.Get (printf "average-%s-conforme-t" $type)) ($data.Get (printf "average-%s-nonconforme-t" $type))) ($data.Get (printf "average-%s-nonapplicable-t" $type))) }}

@bertrandkeller
Copy link

Oui, encore une fois, non prise en compte d'un unique audit 100% quelque chose…

La variable existe pour ne lister que les critères testés sur tous les audits dans les statistiques agrégées, la correction ressemblerait à ça :

{ $dict1 = (dict
    "pourcentage"              ($data.Get (printf "average-%s-pourcentage"     $type))
    "pourcentage100"           ($data.Get (printf "average-%s-pourcentage-100" $type))
    "pourcentage80"            ($data.Get (printf "average-%s-pourcentage-80"  $type))
    "pourcentage50"            ($data.Get (printf "average-%s-pourcentage-50"  $type))
    "pourcentage30"            ($data.Get (printf "average-%s-pourcentage-30"  $type))
    "pourcentage00"            ($data.Get (printf "average-%s-pourcentage-00"  $type))
    "conforme"                 ($data.Get (printf "average-%s-conforme"        $type))
    "nonconforme"              ($data.Get (printf "average-%s-nonconforme"     $type))
    "nonapplicable"            ($data.Get (printf "average-%s-nonapplicable"   $type))
    "all"                      ($data.Get (printf "average-%s-conforme"        $type))
  ) }}
  {{ if and ($data.Get (printf "average-%s-conforme" $type)) ($data.Get (printf "average-%s-nonconforme" $type)) }}
    {{ $dict1 = merge $dict1 (dict "all" (merge ($data.Get (printf "average-%s-conforme" $type)) ($data.Get (printf "average-%s-nonconforme" $type)))) }}
  {{ end }}
  {{ if ($data.Get (printf "average-%s-nonapplicable" $type)) }}
    {{ $dict1 = merge $dict1 (dict "all" ((merge (merge ($data.Get (printf "average-%s-conforme" $type)) ($data.Get (printf "average-%s-nonconforme" $type))) ($data.Get (printf "average-%s-nonapplicable" $type)))))}}
  {{ end }}
  {{ if and ($data.Get (printf "average-%s-nonapplicable" $type)) (not (and ($data.Get (printf "average-%s-conforme" $type)) ($data.Get (printf "average-%s-nonconforme" $type)))) }}
    {{ $dict1 = merge $dict1 (dict "all" ($data.Get (printf "average-%s-nonapplicable" $type))) }}
  {{ end }}
  {{ if and ($data.Get (printf "average-%s-nonconforme" $type)) (not (and ($data.Get (printf "average-%s-conforme" $type)) ($data.Get (printf "average-%s-nonapplicable" $type)))) }}
    {{ $dict1 = merge $dict1 (dict "all" ($data.Get (printf "average-%s-nonconforme" $type))) }}
  {{ end }}

Je trouve pas ça très classieux , mais c'est l'idée.

@marc-bouvier
Copy link
Contributor

Si c'est pas classieux, ça a le mérite d'être explicite et lisible je trouve

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants