forked from StellarSplit/StellarSplit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalytics.controller.ts
More file actions
51 lines (45 loc) · 1.46 KB
/
Copy pathanalytics.controller.ts
File metadata and controls
51 lines (45 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { Controller, Get, Query, Param, Post, Body } from "@nestjs/common";
import { SpendingTrendsDto } from "./dto/spending-trends.dto";
import { ExportRequestDto } from "./dto/export.dto";
import { AnalyticsService } from "./analytics.service";
@Controller("analytics")
export class AnalyticsController {
constructor(private readonly analyticsService: AnalyticsService) {}
@Get("spending-trends")
async getSpendingTrends(@Query() query: SpendingTrendsDto) {
return this.analyticsService.getSpendingTrends(query);
}
@Get("category-breakdown")
async getCategoryBreakdown(@Query() query: SpendingTrendsDto) {
return this.analyticsService.getCategoryBreakdown(query);
}
@Get("top-partners")
async getTopPartners(
@Query("dateFrom") dateFrom?: string,
@Query("dateTo") dateTo?: string,
@Query("userId") userId?: string,
@Query("limit") limit = "10",
) {
return this.analyticsService.getTopPartners({
dateFrom,
dateTo,
userId,
limit: parseInt(limit, 10),
});
}
@Get("monthly-report/:month")
async getMonthlyReport(
@Query("userId") userId: string,
@Param("month") month: string,
) {
return this.analyticsService.getMonthlyReport(month, userId);
}
@Post("export")
async export(@Body() body: ExportRequestDto) {
return this.analyticsService.enqueueExport(body);
}
@Get("reports/:id")
async getReport(@Param("id") id: string) {
return this.analyticsService.getReportStatus(id);
}
}