Skip to content

Commit

Permalink
remove backend + use grist for data
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffreyaldebert committed Jun 10, 2024
1 parent c7d8d44 commit 8ae6a0d
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 140 deletions.
1 change: 0 additions & 1 deletion Procfile

This file was deleted.

21 changes: 0 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,6 @@ npm i
npm run docs:dev
```

### API

ouverture.data.gouv.fr uses pip to install its dependencies. You can create a
[virtualenv](https://realpython.com/blog/python/python-virtual-environments-a-primer/),
activate it and install the requirements with the following commands.

```bash
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
```

Then, you can run the project :

`NOTION_BASE_MINISTERIAL_COMMITMENTS` and `NOTION_BASE_HVD` is the id in the base URL before the `?`: https://www.notion.so/apigouv/[YOUR BASE]?v=ac8f34f3b3874ee2aae5a77219ac3f2f&pvs=4.

```
cd backend
FLASK_DEBUG=1 FLASK_APP=app NOTION_BASE_MINISTERIAL_COMMITMENTS=[ID] NOTION_BASE_HVD=[ID] NOTION_API_KEY=[KEY] flask run
```

## Build

Vitepress has a build mode that generate files in `frontend/dist` to be deployed.
Expand Down
81 changes: 0 additions & 81 deletions backend/app.py

This file was deleted.

24 changes: 0 additions & 24 deletions backend/cli.py

This file was deleted.

17 changes: 17 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
"dependencies": {
"@conciergerie.dev/vitepress-plugin-matomo": "^1.0.3",
"@gouvfr/dsfr": "^1.9.0",
"@vueuse/core": "^10.9.0",
"dotenv": "^16.4.5",
"vitepress": "^1.1.4",
"vue": "^3.4.26",
"vue-loading-overlay": "^6.0.3",
"@vueuse/core": "^10.9.0"
"vue-loading-overlay": "^6.0.3"
}
}
1 change: 1 addition & 0 deletions frontend/site/.vitepress/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env
11 changes: 10 additions & 1 deletion frontend/site/.vitepress/config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { defineConfigWithTheme } from 'vitepress'
import dotenv from 'dotenv';
import { join, dirname } from 'path';
import { fileURLToPath } from 'url';

const __dirname = dirname(fileURLToPath(import.meta.url));
dotenv.config({ path: join(__dirname, '.env') });

// https://vitepress.dev/reference/site-config
/**
Expand Down Expand Up @@ -26,6 +32,9 @@ export default defineConfigWithTheme({
}
},
themeConfig: {
apiUrl: process.env.VUE_APP_API_URL || "http://localhost:5000/api",
yoyo: "tutu",
hvdApiUrl: process.env.VUE_APP_HVD_API_URL,
engagementApiUrl: process.env.VUE_APP_ENGAGEMENT_API_URL,
huhuh: "nubn"
}
});
27 changes: 25 additions & 2 deletions frontend/site/.vitepress/theme/components/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,35 @@ const filteredLines = computed(() => {
return results
})
const loading = ref<'loading' | 'failed' | 'done'>('loading')
const load = async () => {
const { theme } = useData();
try {
const response = await fetch(`${theme.value.apiUrl}/${props.endpoint}`)
lines.value = await response.json()
let url =""
if (props.endpoint === 'high_value_datasets') {
url = theme.value.hvdApiUrl
}
if (props.endpoint === 'ministerial_commitments') {
url = theme.value.engagementApiUrl
}
const response = await fetch(url)
let results = await response.json()
let records = []
results.records.forEach((item) => {
let obj = {}
obj["TITRE"] = item["fields"]["Titre"]
obj["PRODUCTEUR"] = item["fields"]["Producteur"]
obj["STATUT"] = item["fields"]["Statut"]
obj["URL"] = item["fields"]["url"]
if ("Thematique" in item["fields"]) obj["THÉMATIQUE"] = item["fields"]["Thematique"]
if ("Ministere_de_tutelle" in item["fields"]) obj["MINISTÈRE DE TUTELLE"] = item["fields"]["Ministere_de_tutelle"]
if ("Ensemble_de_donnees" in item["fields"]) obj["ENSEMBLE DE DONNÉES"] = item["fields"]["Ensemble_de_donnees"]
if ("Date_estimee" in item["fields"]) obj["DATE ESTIMÉE"] = item["fields"]["Date_estimee"]
records.push(obj)
})
lines.value = records
loading.value = 'done'
} catch (e) {
console.error(e)
Expand Down
5 changes: 0 additions & 5 deletions requirements.txt

This file was deleted.

1 change: 0 additions & 1 deletion runtime.txt

This file was deleted.

2 changes: 0 additions & 2 deletions setup.cfg

This file was deleted.

0 comments on commit 8ae6a0d

Please sign in to comment.