~etalab/codegouvfr-devel

code.gouv.fr: Fix and improve "most used" functions v1 APPLIED

This patch aims to correct the display of "most used" software licenses.
Without sorting the collection (by decreasing order of frequency), the
`(take n)` function would only display the _n_ first items – not
necessarily the most frequent ones.

Presently, the live website
quotes the GNU Affero General Public License v3.0 (with 15.1% share) as
the most frequent license – it isn't, and somehow contradicts the bottom
chart.

Less importantly, this PR aims to improve the consistency of
the `lets` assignments in `(stats-page)`: one of them relied on a string
matching downstream ; the other on a `dissoc` ahead of clean up. We
picked the latter in both instances.

Basile Simon (2):
  Bugfix: Sort "most used" licenses in decreasing order
  Improve consistency of filtering out keys

 src/cljs/codegouvfr/core.cljs | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

-- 
2.32.0
#626136 master.yml success
code.gouv.fr/patches/master.yml: SUCCESS in 5m52s

[Fix and improve "most used" functions][0] from [~basilesimon][1]

[0]: https://lists.sr.ht/~etalab/codegouvfr-devel/patches/26419
[1]: mailto:basile@basilesimon.fr

✓ #626136 SUCCESS code.gouv.fr/patches/master.yml https://builds.sr.ht/~etalab/job/626136
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~etalab/codegouvfr-devel/patches/26419/mbox | git am -3
Learn more about email & git

[PATCH code.gouv.fr 1/2] Bugfix: Sort "most used" licenses in decreasing order Export this patch

From: Basile Simon <basile@basilesimon.fr>

Otherwise, we (take 10) of whichever order they come in.
By chance, they appeared to be sorted before this patch.
---
 src/cljs/codegouvfr/core.cljs | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/cljs/codegouvfr/core.cljs b/src/cljs/codegouvfr/core.cljs
index 2047e70..c50038c 100644
--- a/src/cljs/codegouvfr/core.cljs
+++ b/src/cljs/codegouvfr/core.cljs
@@ -1004,13 +1004,15 @@
        (top-clean-up (walk/stringify-keys top_languages)
                      "language" (i/i lang [:list-repos-with-language]))
        top_licenses_0
        (take 10 (top-clean-up
        (->> (top-clean-up
                  (walk/stringify-keys
                   (-> top_licenses
                       (dissoc :Inconnue)
                       (dissoc :Other)))
                  "license"
                  (i/i lang [:list-repos-using-license])))]
             (i/i lang [:list-repos-using-license]))
            (sort-by val >)
            (take 10))]
    [:div
     [:div.fr-grid-row.fr-grid-row--center
      (stats-tile lang :mean-repos-by-orga avg_repos_cnt)
-- 
2.32.0

[PATCH code.gouv.fr 2/2] Improve consistency of filtering out keys Export this patch

From: Basile Simon <basile@basilesimon.fr>

---
 src/cljs/codegouvfr/core.cljs | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/cljs/codegouvfr/core.cljs b/src/cljs/codegouvfr/core.cljs
index c50038c..324b41a 100644
--- a/src/cljs/codegouvfr/core.cljs
+++ b/src/cljs/codegouvfr/core.cljs
@@ -152,7 +152,6 @@
    (apply merge
           (sequence
            (comp
             (filter (fn [[k _]] (not= k "Inconnu")))
             (map (fn [[k v]]
                    [k (js/parseFloat
                        (gstring/format "%.2f" (* (/ v total) 100)))]))
@@ -1001,8 +1000,10 @@
                               (:count %))
                      top_orgs_by_repos))
        top_languages_1
        (top-clean-up (walk/stringify-keys top_languages)
        (top-clean-up (walk/stringify-keys (-> top_languages
                                               (dissoc :Inconnu)))
                      "language" (i/i lang [:list-repos-with-language]))

        top_licenses_0
        (->> (top-clean-up
                  (walk/stringify-keys
-- 
2.32.0
code.gouv.fr/patches/master.yml: SUCCESS in 5m52s

[Fix and improve "most used" functions][0] from [~basilesimon][1]

[0]: https://lists.sr.ht/~etalab/codegouvfr-devel/patches/26419
[1]: mailto:basile@basilesimon.fr

✓ #626136 SUCCESS code.gouv.fr/patches/master.yml https://builds.sr.ht/~etalab/job/626136