Skip to content

Commit 229867f

Browse files
committed
Updating statistics controller of hashtag
1 parent 088de93 commit 229867f

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

src/main/java/org/kryptokrona/hugin/controller/statistics/latest/StatisticsHashtagController.java

+49
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
package org.kryptokrona.hugin.controller.statistics.latest;
22

3+
import io.swagger.v3.oas.annotations.Operation;
34
import io.swagger.v3.oas.annotations.tags.Tag;
5+
import org.kryptokrona.hugin.http.StatisticsResponse;
46
import org.kryptokrona.hugin.service.HashtagService;
57
import org.springframework.beans.factory.annotation.Autowired;
8+
import org.springframework.http.HttpStatus;
9+
import org.springframework.http.ResponseEntity;
610
import org.springframework.web.bind.annotation.CrossOrigin;
11+
import org.springframework.web.bind.annotation.GetMapping;
712
import org.springframework.web.bind.annotation.RequestMapping;
813
import org.springframework.web.bind.annotation.RestController;
914

@@ -29,4 +34,48 @@ public StatisticsHashtagController(HashtagService hashtagService) {
2934
this.hashtagService = hashtagService;
3035
}
3136

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+
3281
}

0 commit comments

Comments
 (0)