From f11ebc82f5bc31c59de82eb8b9f3bf82771d039c Mon Sep 17 00:00:00 2001 From: dasha Date: Fri, 22 Dec 2023 15:18:00 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B8=D1=82=D0=BE=D0=B3=D0=BE=20=D0=B2=20?= =?UTF-8?q?=D0=BE=D1=82=D1=87=D0=B5=D1=82=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/myapplication/composeui/Report.kt | 1 + server/reportRouter.js | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/example/myapplication/composeui/Report.kt b/app/src/main/java/com/example/myapplication/composeui/Report.kt index b96288f..e7cc3ab 100644 --- a/app/src/main/java/com/example/myapplication/composeui/Report.kt +++ b/app/src/main/java/com/example/myapplication/composeui/Report.kt @@ -134,6 +134,7 @@ fun CardScreen(report: ReportRemote?) { Spacer(modifier = Modifier.height(16.dp)) } Text(text = "Итого: ") + Spacer(modifier = Modifier.height(16.dp)) Row( modifier = Modifier .fillMaxWidth() diff --git a/server/reportRouter.js b/server/reportRouter.js index 1fea4b3..06268ed 100644 --- a/server/reportRouter.js +++ b/server/reportRouter.js @@ -20,6 +20,9 @@ module.exports = (req, res, next) => { sessionDate.setHours(4, 0, 0, 0); return sessionDate >= start && sessionDate <= end; }); + const report = { "report_data": [], + "total_revenue": 0.0, + "total_purchased_tickets": 0 } // Обрабатываем отфильтрованные сеансы для аналитики const reportData = filteredSessions.map(session => { @@ -43,6 +46,8 @@ module.exports = (req, res, next) => { }, { totalTicketsSold: 0, revenue: 0 }); const cinema = cinemas.find(cinema => cinema.id === session.cinemaId) + report.total_revenue += revenue + report.total_purchased_tickets += totalTicketsSold return { cinema_name: cinema ? cinema.name : "Неизвестно", current_ticket_date_time: session.dateTime, @@ -53,10 +58,8 @@ module.exports = (req, res, next) => { }; }); - const sortedReportData = reportData.sort((a, b) => b.revenue - a.revenue); - const report = { "sortedReportData": sortedReportData, - "total_revenue": sortedReportData.reduce((a, b) => a + b.revenue, 0), - "total_purchased_tickets": sortedReportData.reduce((a, b) => a + b.purchased_tickets, 0) } + report.report_data = reportData.sort((a, b) => b.revenue - a.revenue) + res.json(report); } catch (error) { console.error('Error processing report: ', error);