1
1
package org .kryptokrona .hugin .controller .statistics .latest ;
2
2
3
+ import io .swagger .v3 .oas .annotations .Operation ;
3
4
import io .swagger .v3 .oas .annotations .tags .Tag ;
5
+ import org .kryptokrona .hugin .http .StatisticsResponse ;
4
6
import org .kryptokrona .hugin .service .HashtagService ;
5
7
import org .springframework .beans .factory .annotation .Autowired ;
8
+ import org .springframework .http .HttpStatus ;
9
+ import org .springframework .http .ResponseEntity ;
6
10
import org .springframework .web .bind .annotation .CrossOrigin ;
11
+ import org .springframework .web .bind .annotation .GetMapping ;
7
12
import org .springframework .web .bind .annotation .RequestMapping ;
8
13
import org .springframework .web .bind .annotation .RestController ;
9
14
@@ -29,4 +34,48 @@ public StatisticsHashtagController(HashtagService hashtagService) {
29
34
this .hashtagService = hashtagService ;
30
35
}
31
36
37
+ @ GetMapping ("/24h" )
38
+ @ Operation (
39
+ summary = "Amount of hashtags during last 24h" ,
40
+ description = "Gets the total amount of hashtags during last 24h."
41
+ )
42
+ public ResponseEntity <StatisticsResponse > getTotalAmount24h () {
43
+ return new ResponseEntity <>(
44
+ new StatisticsResponse (hashtagService .getTotalItemsBy24h ()),
45
+ HttpStatus .OK );
46
+ }
47
+
48
+ @ GetMapping ("/week" )
49
+ @ Operation (
50
+ summary = "Amount of hashtags during last week" ,
51
+ description = "Gets the total amount of hashtags during last week."
52
+ )
53
+ public ResponseEntity <StatisticsResponse > getTotalAmountWeek () {
54
+ return new ResponseEntity <>(
55
+ new StatisticsResponse (hashtagService .getTotalItemsByWeek ()),
56
+ HttpStatus .OK );
57
+ }
58
+
59
+ @ GetMapping ("/month" )
60
+ @ Operation (
61
+ summary = "Amount of posts during last month" ,
62
+ description = "Gets the total amount of hashtags during last month."
63
+ )
64
+ public ResponseEntity <StatisticsResponse > getTotalAmountMonth () {
65
+ return new ResponseEntity <>(
66
+ new StatisticsResponse (hashtagService .getTotalItemsByMonth ()),
67
+ HttpStatus .OK );
68
+ }
69
+
70
+ @ GetMapping ("/year" )
71
+ @ Operation (
72
+ summary = "Amount of hashtags during last year" ,
73
+ description = "Gets the total amount of hashtags during last year."
74
+ )
75
+ public ResponseEntity <StatisticsResponse > getTotalAmountYear () {
76
+ return new ResponseEntity <>(
77
+ new StatisticsResponse (hashtagService .getTotalItemsByYear ()),
78
+ HttpStatus .OK );
79
+ }
80
+
32
81
}
0 commit comments