From 6fd18cadab5d5b763cda4b18e9f91ab7a48a3b88 Mon Sep 17 00:00:00 2001 From: knee-cola Date: Thu, 8 Aug 2024 21:24:23 +0000 Subject: [PATCH 1/3] traefik izdvojen u zasebni stack --- docker-compose-deploy.yml | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/docker-compose-deploy.yml b/docker-compose-deploy.yml index aa13f4e..985aabf 100644 --- a/docker-compose-deploy.yml +++ b/docker-compose-deploy.yml @@ -4,7 +4,7 @@ version: "3.7" networks: traefik-network: name: "traefik-network" - attachable: true # omogućuje da se mreža može koristiti i iz drugih stackova + external: true mongo-network: name: "mongo-network" attachable: false @@ -71,30 +71,3 @@ services: - traefik.http.services.mongo-express.loadbalancer.server.port=8081 - traefik.http.routers.mongo-express.entrypoints=http - traefik.http.routers.mongo-express.rule=Host(`mongo.rezije.app`) - - reverse-proxy: - image: traefik:v2.3 - command: - # Traefik web konzoli se pristupa preko HTTP, a ne HTTPS - - --api.insecure=true - - --providers.docker - # activates the Swarm Mode (instead of standalone Docker). - # - kada je `false` neće detektirati containere kada se pokrene sa `docker-compose up` - - --providers.docker.swarmMode=true - # prikazuj samo containere koji su nakačeni na Traefik - - --providers.docker.exposedByDefault=false - # "ping" omogućujemo za potrebe healthcheck-a - - --ping=true - - --ping.entryPoint=traefik - #- --accesslog=true - #- --log.level=DEBUG - - --entryPoints.http.address=:3000 - ports: - - "3001:3000" - - "8080:8080" - volumes: - # So that Traefik can listen to the Docker events - - /var/run/docker.sock:/var/run/docker.sock - networks: - - traefik-network - From 103e371d5fa06182033d64b5cfe1893a1aa4394f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Dere=C5=BEi=C4=87?= Date: Mon, 13 Jan 2025 16:05:15 +0100 Subject: [PATCH 2/3] =?UTF-8?q?mongo=20projekcija=20pro=C5=A1irena=20prope?= =?UTF-8?q?rty-em=20"hasAttachment"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/lib/actions/locationActions.ts | 44 ++++++++++++++++++++++-------- app/lib/db-types.ts | 5 ++++ app/ui/BillBadge.tsx | 4 +-- 3 files changed, 40 insertions(+), 13 deletions(-) diff --git a/app/lib/actions/locationActions.ts b/app/lib/actions/locationActions.ts index 86b5799..de608e8 100644 --- a/app/lib/actions/locationActions.ts +++ b/app/lib/actions/locationActions.ts @@ -110,13 +110,32 @@ export const fetchAllLocations = withUser(async (user:AuthenticatedUser, year:nu // fetch all locations for the given year const locations = await dbClient.collection("lokacije") - .find( + .aggregate([ { - userId, - "yearMonth.year": year, + $match: { + userId, + "yearMonth.year": year, + }, }, { - projection: { + $addFields: { + bills: { + $map: { + input: "$bills", + as: "bill", + in: { + _id: "$$bill._id", + name: "$$bill.name", + paid: "$$bill.paid", + payedAmount: "$$bill.payedAmount", + hasAttachment: { $ne: ["$$bill.attachment", null] }, + }, + }, + }, + }, + }, + { + $project: { "_id": 1, // "userId": 0, // "userEmail": 0, @@ -130,17 +149,20 @@ export const fetchAllLocations = withUser(async (user:AuthenticatedUser, year:nu "bills.name": 1, "bills.paid": 1, "bills.payedAmount": 1, + "bills.hasAttachment": 1, // "bills.attachment": 0, // "bills.notes": 0, // "bills.barcodeImage": 1, }, - } - ) - .sort({ - "yearMonth.year": -1, - "yearMonth.month": -1, - name: 1, - }) + }, + { + $sort: { + "yearMonth.year": -1, + "yearMonth.month": -1, + name: 1, + }, + }, + ]) .toArray(); return(locations) diff --git a/app/lib/db-types.ts b/app/lib/db-types.ts index 53337f3..358dc4f 100644 --- a/app/lib/db-types.ts +++ b/app/lib/db-types.ts @@ -42,6 +42,11 @@ export interface Bill { payedAmount?: number | null; /** attached document (optional) */ attachment?: BillAttachment|null; + /** + * true if there an attachment + * @description this field enables us to send this info to the client without sending large attachment - it's an optimization + */ + hasAttachment: boolean; /** (optional) notes */ notes?: string|null; /** (optional) image data containing PDF471 bar code */ diff --git a/app/ui/BillBadge.tsx b/app/ui/BillBadge.tsx index f0e3eda..8de5201 100644 --- a/app/ui/BillBadge.tsx +++ b/app/ui/BillBadge.tsx @@ -7,7 +7,7 @@ export interface BillBadgeProps { bill: Bill }; -export const BillBadge:FC = ({ locationId, bill: { _id: billId, name, paid, attachment }}) => - +export const BillBadge:FC = ({ locationId, bill: { _id: billId, name, paid, hasAttachment }}) => + {name} ; \ No newline at end of file From fef30523a4314cf9aef965092563fe3d94ab6d28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Dere=C5=BEi=C4=87?= Date: Mon, 13 Jan 2025 16:05:48 +0100 Subject: [PATCH 3/3] =?UTF-8?q?a=C5=BEurirana=20verzija=20u=20compose=20da?= =?UTF-8?q?toteci?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose-deploy.yml b/docker-compose-deploy.yml index 990a2e0..c16884e 100644 --- a/docker-compose-deploy.yml +++ b/docker-compose-deploy.yml @@ -13,7 +13,7 @@ networks: services: web-app: - image: utility-bills-tracker:1.32.0 + image: utility-bills-tracker:1.33.1 networks: - traefik-network - mongo-network