-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* user interest statistics * formatter + checkstyle * small change in getUserInterestStatistic logic. add part 2 of user story about how statistics how users behave with habits. * statistic of how users interact with habits (creation, subscription) * delete logs * test for service * sneaky throws to test method * sneaky throws to test method * controller tests * issue * javadoc for new habit repo methods * javadoc for new habit statistic service methods * formatter * Update ManagementHabitStatisticControllerTest.java * Update HabitStatisticServiceImplTest.java * Update ManagementHabitStatisticController.java
- Loading branch information
Showing
17 changed files
with
1,043 additions
and
18 deletions.
There are no files selected for viewing
74 changes: 74 additions & 0 deletions
74
core/src/main/java/greencity/webcontroller/ManagementHabitStatisticController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package greencity.webcontroller; | ||
|
||
import greencity.constant.HttpStatuses; | ||
import greencity.dto.habitstatistic.HabitDateCount; | ||
import greencity.service.HabitStatisticService; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
import lombok.AllArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
@Controller | ||
@AllArgsConstructor | ||
@RequestMapping("/management/habit/statistics") | ||
public class ManagementHabitStatisticController { | ||
HabitStatisticService habitStatisticService; | ||
|
||
@GetMapping | ||
public String getStatisticsPage() { | ||
return "core/management_habit_statistics"; | ||
} | ||
|
||
/** | ||
* Endpoint to retrieve user interest statistics. | ||
* | ||
* @return ResponseEntity containing user interest statistics. | ||
*/ | ||
@Operation(summary = "Retrieve user interest statistics.") | ||
@ApiResponses(value = { | ||
@ApiResponse(responseCode = "200", description = HttpStatuses.OK), | ||
@ApiResponse(responseCode = "403", description = HttpStatuses.FORBIDDEN) | ||
}) | ||
@GetMapping("/interest") | ||
public ResponseEntity<Map<String, Long>> getUserInterestStatistics() { | ||
return ResponseEntity.ok(habitStatisticService.calculateUserInterest()); | ||
} | ||
|
||
/** | ||
* Endpoint to retrieve habit behavior statistics. | ||
* | ||
* @return ResponseEntity containing habit behavior statistics. | ||
*/ | ||
@Operation(summary = "Retrieve statistics of how users behave with habits.") | ||
@ApiResponses(value = { | ||
@ApiResponse(responseCode = "200", description = HttpStatuses.OK), | ||
@ApiResponse(responseCode = "403", description = HttpStatuses.FORBIDDEN) | ||
}) | ||
@GetMapping("/habit-behavior") | ||
public ResponseEntity<Map<String, Long>> getHabitBehaviorStatistics() { | ||
return ResponseEntity.ok(habitStatisticService.calculateHabitBehaviorStatistic()); | ||
} | ||
|
||
/** | ||
* Endpoint to retrieve user interaction with habits(creation, subscription). | ||
* | ||
* @return ResponseEntity containing habit behavior statistics. | ||
*/ | ||
@Operation(summary = "Retrieve statistics of how users interact with habits.") | ||
@ApiResponses(value = { | ||
@ApiResponse(responseCode = "200", description = HttpStatuses.OK), | ||
@ApiResponse(responseCode = "403", description = HttpStatuses.FORBIDDEN) | ||
}) | ||
@GetMapping("/user-interaction") | ||
public ResponseEntity<Map<String, List<HabitDateCount>>> getUserHabitInteractionStatistics( | ||
@RequestParam(defaultValue = "weekly") String range) { | ||
return ResponseEntity.ok(habitStatisticService.calculateInteractions(range)); | ||
} | ||
} |
Oops, something went wrong.