Skip to content

Commit

Permalink
Merge branch 'master' into fix--drink-really-not-found
Browse files Browse the repository at this point in the history
  • Loading branch information
YoanRos committed Sep 9, 2024
2 parents e379d8d + d486128 commit d78cb81
Show file tree
Hide file tree
Showing 15 changed files with 1,391 additions and 750 deletions.
65 changes: 65 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,68 @@
## [1.162.36](https://github.com/SocialGouv/ozensemble/compare/v1.162.35...v1.162.36) (2024-09-08)


### Bug Fixes

* update prisma ([9a94012](https://github.com/SocialGouv/ozensemble/commit/9a94012b73f88f19f7827a293baffd3c24418074))

## [1.162.35](https://github.com/SocialGouv/ozensemble/compare/v1.162.34...v1.162.35) (2024-09-04)


### Bug Fixes

* date format for drinks ([#627](https://github.com/SocialGouv/ozensemble/issues/627)) ([de7ccc9](https://github.com/SocialGouv/ozensemble/commit/de7ccc94b38fd795cbe290f111af7e8f818ea8a3))

## [1.162.34](https://github.com/SocialGouv/ozensemble/compare/v1.162.33...v1.162.34) (2024-09-03)


### Bug Fixes

* version ([978be7b](https://github.com/SocialGouv/ozensemble/commit/978be7b7d9f14af67c5d104e772328359d87d09f))

## [1.162.33](https://github.com/SocialGouv/ozensemble/compare/v1.162.32...v1.162.33) (2024-09-03)


### Bug Fixes

* update libs ([#626](https://github.com/SocialGouv/ozensemble/issues/626)) ([5e0787c](https://github.com/SocialGouv/ozensemble/commit/5e0787cd65eff0f5a01cd8556993da7dcc007bcb))

## [1.162.32](https://github.com/SocialGouv/ozensemble/compare/v1.162.31...v1.162.32) (2024-08-26)


### Bug Fixes

* notifications url ([382a9d3](https://github.com/SocialGouv/ozensemble/commit/382a9d3ae482c2ffe9a1aabf18575b74f6b43e9d))

## [1.162.31](https://github.com/SocialGouv/ozensemble/compare/v1.162.30...v1.162.31) (2024-08-26)


### Bug Fixes

* tab ipad ([dc1de6b](https://github.com/SocialGouv/ozensemble/commit/dc1de6b2a42e9a4adc4dc08ae0ac3d2798036a40))

## [1.162.30](https://github.com/SocialGouv/ozensemble/compare/v1.162.29...v1.162.30) (2024-08-23)


### Bug Fixes

* switch button ([49b0f16](https://github.com/SocialGouv/ozensemble/commit/49b0f16c9bab576514e5173eab9264233f6bea2b))

## [1.162.29](https://github.com/SocialGouv/ozensemble/compare/v1.162.28...v1.162.29) (2024-08-19)


### Bug Fixes

* update flash-list ([d23c4f5](https://github.com/SocialGouv/ozensemble/commit/d23c4f53c47b5e1f1b8d11de2906456a12eedad0))

## [1.162.28](https://github.com/SocialGouv/ozensemble/compare/v1.162.27...v1.162.28) (2024-08-19)


### Bug Fixes

* change own conso ([#622](https://github.com/SocialGouv/ozensemble/issues/622)) ([64de0d6](https://github.com/SocialGouv/ozensemble/commit/64de0d6cdc04ee22c5617cd688728fe278ea8f2c))
* diagram numbers ([#623](https://github.com/SocialGouv/ozensemble/issues/623)) ([7bba8e5](https://github.com/SocialGouv/ozensemble/commit/7bba8e5b18513f9b46642df4245df3e425135ed1))
* privacy policy ([#624](https://github.com/SocialGouv/ozensemble/issues/624)) ([e892bf5](https://github.com/SocialGouv/ozensemble/commit/e892bf51a045a18afc50ca0e9ec36977b17981ec))

## [1.162.27](https://github.com/SocialGouv/ozensemble/compare/v1.162.26...v1.162.27) (2024-08-08)


Expand Down
2 changes: 1 addition & 1 deletion api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"node-cron": "3.0.2",
"node-fetch": "2.6.7",
"node-pushnotifications": "^3.1.1",
"prisma": "5.16.2",
"prisma": "5.19.1",
"uuid": "^10.0.0"
},
"devDependencies": {
Expand Down
86 changes: 36 additions & 50 deletions api/src/controllers/consommation.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,77 +18,63 @@ router.post(
router.post(
"/sync",
catchErrors(async (req, res) => {
const matomoId = req.body?.matomoId;
if (!matomoId) return res.status(400).json({ ok: false, error: "no matomo id" });
try {
const matomoId = req.body?.matomoId;
if (!matomoId) return res.status(400).json({ ok: false, error: "no matomo id" });

const { drinks, drinksCatalog } = req.body;
const { drinks, drinksCatalog } = req.body;

if (!drinks.length) {
await syncDrinkBadgesWithConsos(matomoId);
if (!drinks.length) {
await syncDrinkBadgesWithConsos(matomoId);

await syncAllGoalsWithConsos(matomoId, true);
await syncAllGoalsWithConsos(matomoId, true);

// TODO: uncomment this line when the notifications for goals sync is sent
// await syncBadgesWithGoals(matomoId, true);
return res.status(200).json({ ok: true });
}
// TODO: uncomment this line when the notifications for goals sync is sent
// await syncBadgesWithGoals(matomoId, true);
return res.status(200).json({ ok: true });
}

const user = await prisma.user.upsert({
where: { matomo_id: matomoId },
create: {
matomo_id: matomoId,
},
update: {},
});
const user = await prisma.user.upsert({
where: { matomo_id: matomoId },
create: {
matomo_id: matomoId,
},
update: {},
});

for (const drink of drinks) {
if (drink.drinkKey === "no-conso") {
for (const drink of drinks) {
const drinkToSave = {
id: drink.id,
drinkKey: drink.drinkKey,
name: drink.drinkKey,
name: drink.drinkKey === "no-conso" ? drink.drinkKey : drinksCatalog.find((dc) => dc.drinkKey === drink.drinkKey)?.displayDrinkModal,
quantity: Number(drink.quantity),
date: dayjs(drink.timestamp).format(),
date: dayjs(drink.timestamp).toISOString(),
userId: user.id,
doses: 0,
kcal: 0,
price: 0,
volume: "",
doses: drink.drinkKey === "no-conso" ? 0 : Number(drinksCatalog.find((dc) => dc.drinkKey === drink.drinkKey)?.doses),
kcal: drink.drinkKey === "no-conso" ? 0 : Number(drinksCatalog.find((dc) => dc.drinkKey === drink.drinkKey)?.kcal),
price: drink.drinkKey === "no-conso" ? 0 : Number(drinksCatalog.find((dc) => dc.drinkKey === drink.drinkKey)?.price),
volume: drink.drinkKey === "no-conso" ? "" : drinksCatalog.find((dc) => dc.drinkKey === drink.drinkKey)?.volume,
};
return await prisma.consommation.upsert({

await prisma.consommation.upsert({
where: { id: drink.id },
update: drinkToSave,
create: drinkToSave,
});
}
const drinkFromCatalog = drinksCatalog.find((drinkCatalog) => drinkCatalog.drinkKey === drink.drinkKey);
const drinkToSave = {
id: drink.id,
drinkKey: drink.drinkKey,
name: drinkFromCatalog.displayDrinkModal,
quantity: drink.quantity,
date: dayjs(drink.timestamp).format(),
userId: user.id,
doses: Number(drinkFromCatalog.doses),
kcal: Number(drinkFromCatalog.kcal),
price: Number(drinkFromCatalog.price),
volume: drinkFromCatalog.volume,
};
await prisma.consommation.upsert({
where: { id: drink.id },
update: drinkToSave,
create: drinkToSave,
});
}

await syncDrinkBadgesWithConsos(matomoId);
await syncDrinkBadgesWithConsos(matomoId);

await syncAllGoalsWithConsos(matomoId, true);
await syncAllGoalsWithConsos(matomoId, true);

// TODO: uncomment this line when the notifications for goals sync is sent
// await syncBadgesWithGoals(matomoId, true);
// TODO: uncomment this line when the notifications for goals sync is sent
// await syncBadgesWithGoals(matomoId, true);

return res.status(200).send({ ok: true });
return res.status(200).send({ ok: true });
} catch (error) {
console.error("An error occurred during syncing:", error);
return res.status(500).json({ ok: false, error: "An internal server error occurred." });
}
})
);

Expand Down
96 changes: 50 additions & 46 deletions api/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -999,49 +999,49 @@ __metadata:
languageName: node
linkType: hard

"@prisma/debug@npm:5.16.2":
version: 5.16.2
resolution: "@prisma/debug@npm:5.16.2"
checksum: 63dac1010cb8304f512b84c903209f4f5b3d8a359284b576101d11e457af9af4eb57e78a1445e101e9e4a6801cdd04e299f12dd0a50eb26fd785387f6c0986b7
"@prisma/debug@npm:5.19.1":
version: 5.19.1
resolution: "@prisma/debug@npm:5.19.1"
checksum: 4b88719b9a0dd76692bec766fd8188b685a81f0459f3df8fb44b4c492b483a6aadaf7021f7aca90afa5a2f27d84d737a3f2d5abed5f9f818a640487f49d1b8c4
languageName: node
linkType: hard

"@prisma/engines-version@npm:5.16.0-24.34ace0eb2704183d2c05b60b52fba5c43c13f303":
version: 5.16.0-24.34ace0eb2704183d2c05b60b52fba5c43c13f303
resolution: "@prisma/engines-version@npm:5.16.0-24.34ace0eb2704183d2c05b60b52fba5c43c13f303"
checksum: de02aed86429fbae0c98dbcb35baa9e1583a37aa222692a832a24153ed173a5559257c31296ecbd8ae5a8a99887f3aaf0797d819ca45e562905ce0bea411fe75
"@prisma/engines-version@npm:5.19.1-2.69d742ee20b815d88e17e54db4a2a7a3b30324e3":
version: 5.19.1-2.69d742ee20b815d88e17e54db4a2a7a3b30324e3
resolution: "@prisma/engines-version@npm:5.19.1-2.69d742ee20b815d88e17e54db4a2a7a3b30324e3"
checksum: 9bf4ad5b199054fe56a96ddbda1b835e7f103d690d2b7d04c159f29399261356516ec8881e8caf637bd4523395ccc4ce450013a0c9a8a3ffa16d2fc15b93bfa8
languageName: node
linkType: hard

"@prisma/engines@npm:5.16.2":
version: 5.16.2
resolution: "@prisma/engines@npm:5.16.2"
"@prisma/engines@npm:5.19.1":
version: 5.19.1
resolution: "@prisma/engines@npm:5.19.1"
dependencies:
"@prisma/debug": "npm:5.16.2"
"@prisma/engines-version": "npm:5.16.0-24.34ace0eb2704183d2c05b60b52fba5c43c13f303"
"@prisma/fetch-engine": "npm:5.16.2"
"@prisma/get-platform": "npm:5.16.2"
checksum: 4e059639779402c9446b2d4795f7cc6b17ef1e9eb85f000a8b591d45fc755fbe66d49b6acec7ed2fd2847b4ffd48fefdc961a9e2439a24de53e59447e03179b5
"@prisma/debug": "npm:5.19.1"
"@prisma/engines-version": "npm:5.19.1-2.69d742ee20b815d88e17e54db4a2a7a3b30324e3"
"@prisma/fetch-engine": "npm:5.19.1"
"@prisma/get-platform": "npm:5.19.1"
checksum: d12893935d842fea1c5344e3ab0f769b01ec1c71a91bec3ac9ceb58838fe7f745d226d5b8b9ac386ad503c56773272586bb73188d592ec8d4e05f43285009155
languageName: node
linkType: hard

"@prisma/fetch-engine@npm:5.16.2":
version: 5.16.2
resolution: "@prisma/fetch-engine@npm:5.16.2"
"@prisma/fetch-engine@npm:5.19.1":
version: 5.19.1
resolution: "@prisma/fetch-engine@npm:5.19.1"
dependencies:
"@prisma/debug": "npm:5.16.2"
"@prisma/engines-version": "npm:5.16.0-24.34ace0eb2704183d2c05b60b52fba5c43c13f303"
"@prisma/get-platform": "npm:5.16.2"
checksum: 00b63683df0278bdcfa4b88756189359dbe03ac5a08f33db29cba839fd9f5c97818608ac9ddc4bc99e407957e7227a5bb6dbb08d64c709835af097a607da78aa
"@prisma/debug": "npm:5.19.1"
"@prisma/engines-version": "npm:5.19.1-2.69d742ee20b815d88e17e54db4a2a7a3b30324e3"
"@prisma/get-platform": "npm:5.19.1"
checksum: 670d3f604549c4778d32febe56d948896b5c16dad5b51814c5b168a6007c9782d453cebee43cb81ddd58c9e9538811ea1a793516420ecf2c84ae4c3b4ed34f6c
languageName: node
linkType: hard

"@prisma/get-platform@npm:5.16.2":
version: 5.16.2
resolution: "@prisma/get-platform@npm:5.16.2"
"@prisma/get-platform@npm:5.19.1":
version: 5.19.1
resolution: "@prisma/get-platform@npm:5.19.1"
dependencies:
"@prisma/debug": "npm:5.16.2"
checksum: 4a9cb31411944e59f8fd678c38e40de8f52dcb931a63f95bd33b951157c5d61229d5d0c5928fd9450a49edcb0723cabf239e65c6f277488af7cb36d45bb125c4
"@prisma/debug": "npm:5.19.1"
checksum: a53b5c894cf4074af6164d9c503e387aba92c518ad7bad82be40f834a0030270c60f6149b20951c3e1db32bd836f582053e63c4bf7099461f0160dd5956f063e
languageName: node
linkType: hard

Expand Down Expand Up @@ -1712,7 +1712,7 @@ __metadata:
node-fetch: "npm:2.6.7"
node-pushnotifications: "npm:^3.1.1"
nodemon: "npm:3.1.4"
prisma: "npm:5.16.2"
prisma: "npm:5.19.1"
superagent: "npm:8.1.2"
supertest: "npm:6.3.4"
typescript: "npm:^5.5.3"
Expand Down Expand Up @@ -4265,6 +4265,16 @@ __metadata:
languageName: node
linkType: hard

"fsevents@npm:2.3.3, fsevents@npm:^2.3.2, fsevents@npm:~2.3.2":
version: 2.3.3
resolution: "fsevents@npm:2.3.3"
dependencies:
node-gyp: "npm:latest"
checksum: a1f0c44595123ed717febbc478aa952e47adfc28e2092be66b8ab1635147254ca6cfe1df792a8997f22716d4cbafc73309899ff7bfac2ac3ad8cf2e4ecc3ec60
conditions: os=darwin
languageName: node
linkType: hard

"fsevents@npm:^1.0.0":
version: 1.2.13
resolution: "fsevents@npm:1.2.13"
Expand All @@ -4276,12 +4286,11 @@ __metadata:
languageName: node
linkType: hard

"fsevents@npm:^2.3.2, fsevents@npm:~2.3.2":
"fsevents@patch:fsevents@npm%3A2.3.3#optional!builtin<compat/fsevents>, fsevents@patch:fsevents@npm%3A^2.3.2#optional!builtin<compat/fsevents>, fsevents@patch:fsevents@npm%3A~2.3.2#optional!builtin<compat/fsevents>":
version: 2.3.3
resolution: "fsevents@npm:2.3.3"
resolution: "fsevents@patch:fsevents@npm%3A2.3.3#optional!builtin<compat/fsevents>::version=2.3.3&hash=df0bf1"
dependencies:
node-gyp: "npm:latest"
checksum: a1f0c44595123ed717febbc478aa952e47adfc28e2092be66b8ab1635147254ca6cfe1df792a8997f22716d4cbafc73309899ff7bfac2ac3ad8cf2e4ecc3ec60
conditions: os=darwin
languageName: node
linkType: hard
Expand All @@ -4296,15 +4305,6 @@ __metadata:
languageName: node
linkType: hard

"fsevents@patch:fsevents@npm%3A^2.3.2#optional!builtin<compat/fsevents>, fsevents@patch:fsevents@npm%3A~2.3.2#optional!builtin<compat/fsevents>":
version: 2.3.3
resolution: "fsevents@patch:fsevents@npm%3A2.3.3#optional!builtin<compat/fsevents>::version=2.3.3&hash=df0bf1"
dependencies:
node-gyp: "npm:latest"
conditions: os=darwin
languageName: node
linkType: hard

"function-bind@npm:^1.1.2":
version: 1.1.2
resolution: "function-bind@npm:1.1.2"
Expand Down Expand Up @@ -7123,14 +7123,18 @@ __metadata:
languageName: node
linkType: hard

"prisma@npm:5.16.2":
version: 5.16.2
resolution: "prisma@npm:5.16.2"
"prisma@npm:5.19.1":
version: 5.19.1
resolution: "prisma@npm:5.19.1"
dependencies:
"@prisma/engines": "npm:5.16.2"
"@prisma/engines": "npm:5.19.1"
fsevents: "npm:2.3.3"
dependenciesMeta:
fsevents:
optional: true
bin:
prisma: build/index.js
checksum: 0820150bfe2f9372b34b97be694554fe8ceb51542e467df0afed94575c425556b534bf8080d8526544c5d3ec339c43072360abfe6b14319b65a0480b116aa983
checksum: efbe4966fc5450e8c3c7e09f8e9950c2068e90f44b1cbb3584f4e48d7188a4d5230ec8fb12c3b9ba75fa7407fe45c0527123579e121a31ef652512f39c29c2d9
languageName: node
linkType: hard

Expand Down
4 changes: 2 additions & 2 deletions expo/app.versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"buildNumber": 309,
"buildName": "1.26.2"
"buildNumber": 313,
"buildName": "1.26.5"
}
Loading

0 comments on commit d78cb81

Please sign in to comment.