Skip to content

Commit 6e0aab5

Browse files
Merge branch 'app-developement' of https://github.com/Libertech-FR/teaket into app-developement
2 parents bdc8d93 + 75c3b06 commit 6e0aab5

File tree

18 files changed

+713
-28
lines changed

18 files changed

+713
-28
lines changed

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,7 @@ buildseeds: ## Build populate image
6666
docker build -t seeding -f ./populate/Dockerfile ./populate
6767

6868
populate-db: ## Populate database
69-
docker run --rm --network dev -v ./populate:/app -v ./service/.dev-token.json:/app/.dev-token.json seeding
69+
docker run --rm --network dev -v $(CURDIR)/populate:/app -v $(CURDIR)/service/.dev-token.json:/app/.dev-token.json seeding
70+
71+
populate-from-gaiasys: ## Populate database
72+
docker run --rm --network dev -v $(CURDIR)/populate:/app -v $(CURDIR)/service/.dev-token.json:/app/.dev-token.json seeding python populate_from_gaiasys.py

app/src/components/searchfilters/Main.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ const comparatorTypes = ref<Comparator[]>([
7171
{ label: 'Inférieur à', querySign: '<', value: '<', icon: 'mdi-less-than', type: ['number', 'date'], multiplefields: false, prefix: '', suffix: '' },
7272
{ label: 'Inférieur ou égal à', querySign: '<=', value: '<=', icon: 'mdi-less-than-or-equal', type: ['number', 'date'], multiplefields: false, prefix: '', suffix: '' },
7373
{ label: 'entre', querySign: '<<', value: 'between', icon: 'mdi-arrow-expand-horizontal', type: ['number', 'date'], multiplefields: true, prefix: '', suffix: '' },
74-
{ label: 'Contiens', querySign: '^', value: '^', icon: 'mdi-apple-keyboard-control', type: ['text'], multiplefields: false, prefix: '/', suffix: '/' },
74+
{ label: 'Contiens', querySign: '^', value: '^', icon: 'mdi-apple-keyboard-control', type: ['text'], multiplefields: false, prefix: '/', suffix: '/i' },
7575
{ label: 'Commence par', querySign: '^', value: '/^', icon: 'mdi-apple-keyboard-control', type: ['text'], multiplefields: false, prefix: '/^', suffix: '/' },
7676
{ label: 'Fini par', querySign: '^', value: '$/', icon: 'mdi-apple-keyboard-control', type: ['text'], multiplefields: false, prefix: '/', suffix: '$/' },
7777
{ label: 'Egal à', querySign: '@', value: '@', icon: 'mdi-apple-keyboard-control', type: [], multiplefields: true, prefix: '', suffix: '' },

app/src/error.example.vue

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<template>
2+
<div>
3+
<p>{{ error.statusCode }}</p>
4+
<p>{{ error.message }}</p>
5+
</div>
6+
</template>
7+
8+
<script lang='ts' setup>
9+
import { NuxtError } from '#app'
10+
11+
defineProps({
12+
error: {
13+
type: Object as PropType<NuxtError>,
14+
default: null,
15+
},
16+
})
17+
</script>

app/src/plugins/fetch-catch.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export default defineNuxtPlugin((nuxtApp) => {
2+
// nuxtApp.vueApp.config.errorHandler = (error, context) => {
3+
// console.log('errorHandler', error, context)
4+
// // return showError({ statusCode: 404, statusMessage: 'nnnnnnnnnnnnn' })
5+
// }
6+
})

populate/.editorconfig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
max_line_length = 120
12+
13+
[Makefile]
14+
indent_style = tab
15+
16+
[*.md]
17+
trim_trailing_whitespace = false
18+
19+
[*.py]
20+
indent_size = 4

populate/populate_data.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
# Get the MongoDB URL from the environment variables
1616
mongo_url = os.getenv("MONGODB_URL")
17+
token_path = os.path.join(os.path.dirname(__file__), '.dev-token.json')
1718
collections = [
1819
{
1920
"name": "identities",
@@ -88,24 +89,35 @@
8889

8990
api_endpoint = os.getenv("API_BASE_URL")
9091

91-
async def populate_collection(collection):
92+
93+
async def populate_collection(collection, token):
9294
logger.info(f"Populating {collection.get('name')}...")
9395
file_path = os.path.join(os.path.dirname(__file__), 'seeds', collection.get('file'))
96+
headers = {
97+
"Authorization": f"Bearer {token}", "Content-Type": "application/json; charset=utf-8"
98+
}
9499
with open(file_path) as f:
95100
datas = json.load(f)
96101
for data in datas:
97102
try:
98-
response = requests.post(f"{api_endpoint}/{collection.get('endpoint')}", json=data)
103+
response = requests.post(f"{api_endpoint}/{collection.get('endpoint')}", headers=headers, json=data)
99104
response.raise_for_status()
100105
logger.info(f"{collection.get('name')} inserted")
101106
except Exception as e:
102107
logger.warning(f"Failed to insert {collection.get('name')}: {e}")
108+
error_message = response.json().get('message')
109+
logger.warning(f"Failed to insert {collection.get('name')}: {error_message}")
110+
103111

104112
async def main():
105-
collection_tasks = [populate_collection(col) for col in collections]
113+
with open(token_path) as f:
114+
token = json.load(f).get("access_token")
115+
logger.info(f"Load DEV Token <{token}>")
116+
collection_tasks = [populate_collection(col, token) for col in collections]
106117
await asyncio.gather(*collection_tasks)
107118

108119
print("DB populated")
109120

121+
110122
if __name__ == "__main__":
111-
asyncio.run(main())
123+
asyncio.run(main())

0 commit comments

Comments
 (0)