Skip to content
Permalink
Browse files

Add endpoint /stats/last_repositories

  • Loading branch information...
AntoineAugusti committed Jul 2, 2019
1 parent e214f25 commit 2a0bba602c2f854170e3b9ead85b87b52eb26442
Showing with 25 additions and 0 deletions.
  1. +3 −0 README.md
  2. +2 −0 _redirects
  3. +3 −0 build.sh
  4. +17 −0 stats.py
@@ -58,5 +58,8 @@ Exemple :
}
```

### Statistiques
- `/stats/last_repositories` : les 10 derniers répertoires créés

## Licence
MIT
@@ -2,3 +2,5 @@

/api/repertoires/:slug /data-codes-sources-fr-master/data/repertoires/json/:slug.json 200
/api/organisations/:slug /data-codes-sources-fr-master/data/organisations/json/:slug.json 200

/api/stats/:slug /stats/:slug.json 200
@@ -1,2 +1,5 @@
wget https://github.com/etalab/data-codes-sources-fr/archive/master.zip
unzip master.zip "*.json"
mkdir stats

python stats.py
@@ -0,0 +1,17 @@
import json

IN_FOLDER = "data-codes-sources-fr-master/data/"
OUT_FOLDER = "stats/"

with open(IN_FOLDER + "repertoires/json/all.json") as f:
repertoires = json.load(f)


def last_repositories(repertoires):
last_repo = sorted(repertoires, key=lambda k: k["date_creation"], reverse=True)[:10]

with open(OUT_FOLDER + "last_repositories.json", "w") as f:
json.dump(last_repo, f)


last_repositories(repertoires)

0 comments on commit 2a0bba6

Please sign in to comment.
You can’t perform that action at this time.