Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Commit

Permalink
feat(ci): add seeds command (#28)
Browse files Browse the repository at this point in the history
* Test .env

* feat: add db deploy

* Use proper DB URL

* fix: use devInitContainerCommand

* Do a db migration in docker

* run db:migrate

* Fix build

Co-authored-by: Desoindx <xavier.desoindre@hotmail.fr>
  • Loading branch information
Julien Bouquillon and desoindx authored Jan 11, 2022
1 parent 210514c commit 36048fc
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 12 deletions.
4 changes: 3 additions & 1 deletion .socialgouv/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
"type": "app",
"subdomain": "monpsy",
"registry": "ghcr",
"project": "mon-psy-sante"
"project": "mon-psy-sante",
"azurepg": true,
"devInitContainerCommand": ["yarn", "db:init"]
}
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ ENV NODE_ENV production
COPY --from=builder /app/next.config.js .
COPY --from=builder /app/sentry.client.config.js .
COPY --from=builder /app/sentry.server.config.js .
COPY --from=builder /app/.sequelizerc .
COPY --from=builder /app/.env.production .
COPY --from=builder /app/package.json .
COPY --from=builder /app/src ./src
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"axios": "^0.24.0",
"cron": "^1.8.2",
"dotenv": "^11.0.0",
"faker": "^6.6.6",
"faker": "^5.5.3",
"graphql": "^16.2.0",
"graphql-request": "^3.7.0",
"leaflet": "^1.7.1",
Expand Down Expand Up @@ -61,9 +61,10 @@
"lint": "eslint ./src",
"lint:fix": "eslint ./src --fix",
"precommit": "lint-staged",
"start": "NODE_ENV=production next start",
"start": "yarn run db:migrate && NODE_ENV=production next start",
"export": "next export",
"db:seed": "ts-node src/db/seeds/index.ts",
"db:init": "yarn run db:migrate && yarn run db:seed",
"db:seed": "ts-node --transpile-only src/db/seeds/index.ts",
"db:migrate": "npx sequelize-cli db:migrate",
"db:migrate:undo": "npx sequelize-cli db:migrate:undo",
"db:migrate:create": "npx sequelize migration:create --name"
Expand Down
9 changes: 7 additions & 2 deletions src/components/Directory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import React, { useEffect, useRef, useState } from "react";
import { Coordinates } from "../types/coordinates";
import { FILTER } from "../types/enums/filters";
import { Psychologist } from "../types/psychologist";
import { departments, getDepartment } from "./utils/departments";
import { getDepartment } from "./utils/departments";

const AROUND_ME = "Autour de moi";
const AROUND_ME_OPTION = [{ label: AROUND_ME, value: AROUND_ME }];
Expand Down Expand Up @@ -109,6 +109,7 @@ const Directory = () => {
if (filter === AROUND_ME) {
checkGeolocationPermission();
} else if (filter && typeof filter === "string") {
setGeoLoading(true);
axios
.get(
`https://api-adresse.data.gouv.fr/search/?q=${filter}&postCode=${filter}`
Expand All @@ -119,6 +120,7 @@ const Directory = () => {
latitude: coordinates[1],
longitude: coordinates[0],
});
setGeoLoading(false);
});
} else if (filter) {
const coordinates = filter.split("-");
Expand Down Expand Up @@ -214,7 +216,10 @@ const Directory = () => {
label="Rechercher par ville, code postal ou région"
options={options}
/>
<Button disabled={!coords} onClick={() => loadPsychologists()}>
<Button
disabled={!coords && !geoLoading}
onClick={() => loadPsychologists()}
>
Rechercher
</Button>
{filter === AROUND_ME && geoStatus === geoStatusEnum.DENIED && (
Expand Down
4 changes: 2 additions & 2 deletions src/services/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as dotenv from "dotenv";

dotenv.config();

const parseBoolean = (value: string) => value === "true";
const parseBoolean = (value: string | undefined) => value === "true";

export default {
demarchesSimplifiees: {
Expand All @@ -15,6 +15,6 @@ export default {
minScoreAddress: parseFloat(process.env.MIN_SCORE_ADDRESS || "0.55"),
postgre: {
logging: parseBoolean(process.env.DB_LOGGING_ENABLE),
url: process.env.DATABASE_URL,
url: process.env.DATABASE_URL || "",
},
};
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3462,10 +3462,10 @@ extract-files@^9.0.0:
resolved "https://registry.yarnpkg.com/extract-files/-/extract-files-9.0.0.tgz#8a7744f2437f81f5ed3250ed9f1550de902fe54a"
integrity sha512-CvdFfHkC95B4bBBk36hcEmvdR2awOdhhVUYH6S/zrVj3477zven/fJMYg7121h4T1xHZC+tetUpubpAhxwI7hQ==

faker@^6.6.6:
version "6.6.6"
resolved "https://registry.yarnpkg.com/faker/-/faker-6.6.6.tgz#e9529da0109dca4c7c5dbfeaadbd9234af943033"
integrity sha512-9tCqYEDHI5RYFQigXFwF1hnCwcWCOJl/hmll0lr5D2Ljjb0o4wphb69wikeJDz5qCEzXCoPvG6ss5SDP6IfOdg==
faker@^5.5.3:
version "5.5.3"
resolved "https://registry.yarnpkg.com/faker/-/faker-5.5.3.tgz#c57974ee484431b25205c2c8dc09fda861e51e0e"
integrity sha512-wLTv2a28wjUyWkbnX7u/ABZBkUkIF2fCd73V6P2oFqEGEktDfzWx4UxrSqtPRw0xPRAcjeAOIiJWqZm3pP4u3g==

fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3:
version "3.1.3"
Expand Down

0 comments on commit 36048fc

Please sign in to comment.