-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
988 additions
and
0 deletions.
There are no files selected for viewing
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
150 changes: 150 additions & 0 deletions
150
src/main/java/org/avniproject/etl/controller/ReportController.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,150 @@ | ||
package org.avniproject.etl.controller; | ||
|
||
import org.avniproject.etl.domain.OrgIdentityContextHolder; | ||
import org.avniproject.etl.dto.AggregateReportResult; | ||
import org.avniproject.etl.dto.UserActivityDTO; | ||
import org.avniproject.etl.repository.ReportRepository; | ||
import org.avniproject.etl.util.ReportUtil; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.security.access.prepost.PreAuthorize; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
public class ReportController { | ||
|
||
private final ReportRepository reportRepository; | ||
private final ReportUtil reportUtil; | ||
|
||
@Autowired | ||
public ReportController(ReportRepository reportRepository, ReportUtil reportUtil) { | ||
this.reportRepository = reportRepository; | ||
this.reportUtil = reportUtil; | ||
} | ||
|
||
@PreAuthorize("hasAnyAuthority('analytics_user')") | ||
@RequestMapping(value = "/report/aggregate/summaryTable", method = RequestMethod.GET) | ||
public List<UserActivityDTO> getSummaryTable(@RequestParam(value = "startDate", required = false) String startDate, | ||
@RequestParam(value = "endDate", required = false) String endDate, | ||
@RequestParam(value = "userIds", required = false, defaultValue = "") List<Long> userIds){ | ||
return reportRepository.generateSummaryTable( | ||
OrgIdentityContextHolder.getDbSchema() | ||
); | ||
} | ||
|
||
@PreAuthorize("hasAnyAuthority('analytics_user')") | ||
@RequestMapping(value = "report/hr/userActivity", method = RequestMethod.GET) | ||
public List<UserActivityDTO> getUserActivity(@RequestParam(value = "startDate", required = false) String startDate, | ||
@RequestParam(value = "endDate", required = false) String endDate, | ||
@RequestParam(value = "userIds", required = false, defaultValue = "") List<Long> userIds){ | ||
return reportRepository.generateUserActivity( | ||
OrgIdentityContextHolder.getDbSchema(), | ||
reportUtil.getDateDynamicWhere(startDate, endDate, "registration_date"), | ||
reportUtil.getDateDynamicWhere(startDate, endDate, "encounter_date_time"), | ||
reportUtil.getDateDynamicWhere(startDate, endDate, "enrolment_date_time"), | ||
reportUtil.getDynamicUserWhere(userIds, "u.id") | ||
); | ||
} | ||
|
||
@PreAuthorize("hasAnyAuthority('analytics_user')") | ||
@RequestMapping(value = "/report/hr/syncFailures",method = RequestMethod.GET) | ||
public List<UserActivityDTO> getUserWiseSyncFailures(@RequestParam(value = "startDate", required = false) String startDate, | ||
@RequestParam(value = "endDate", required = false) String endDate, | ||
@RequestParam(value = "userIds", required = false, defaultValue = "") List<Long> userIds){ | ||
return reportRepository.generateUserSyncFailures( | ||
OrgIdentityContextHolder.getDbSchema(), | ||
reportUtil.getDateDynamicWhere(startDate, endDate, "st.sync_start_time"), | ||
reportUtil.getDynamicUserWhere(userIds, "u.id") | ||
); | ||
} | ||
|
||
@PreAuthorize("hasAnyAuthority('analytics_user')") | ||
@RequestMapping(value = "/report/hr/deviceModels", method = RequestMethod.GET) | ||
public List<AggregateReportResult> getUserWiseDeviceModels(@RequestParam(value = "userIds", required = false, defaultValue = "") List<Long> userIds) { | ||
|
||
return reportRepository.generateUserDeviceModels( | ||
OrgIdentityContextHolder.getDbSchema(), | ||
reportUtil.getDynamicUserWhere(userIds, "u.id")); | ||
} | ||
|
||
@PreAuthorize("hasAnyAuthority('analytics_user')") | ||
@RequestMapping(value = "/report/hr/appVersions", method = RequestMethod.GET) | ||
public List<AggregateReportResult> getUserWiseAppVersions(@RequestParam(value = "userIds", required = false, defaultValue = "") List<Long> userIds) { | ||
|
||
return reportRepository.generateUserAppVersions( | ||
OrgIdentityContextHolder.getDbSchema(), | ||
reportUtil.getDynamicUserWhere(userIds, "u.id")); | ||
} | ||
|
||
@PreAuthorize("hasAnyAuthority('analytics_user')") | ||
@RequestMapping(value = "/report/hr/userDetails", method = RequestMethod.GET) | ||
public List<UserActivityDTO> getUserDetails(@RequestParam(value = "userIds", required = false, defaultValue = "") List<Long> userIds) { | ||
|
||
return reportRepository.generateUserDetails( | ||
OrgIdentityContextHolder.getDbSchema(), | ||
reportUtil.getDynamicUserWhere(userIds, "u.id")); | ||
} | ||
|
||
@PreAuthorize("hasAnyAuthority('analytics_user')") | ||
@RequestMapping(value = "/report/hr/latestSyncs", method = RequestMethod.GET) | ||
public List<UserActivityDTO> getLatestSyncs(@RequestParam(value = "startDate", required = false) String startDate, | ||
@RequestParam(value = "endDate", required = false) String endDate, | ||
@RequestParam(value = "userIds", required = false, defaultValue = "") List<Long> userIds) { | ||
|
||
return reportRepository.generateLatestSyncs( | ||
OrgIdentityContextHolder.getDbSchema(), | ||
reportUtil.getDateDynamicWhere(startDate, endDate, "st.sync_end_time"), | ||
reportUtil.getDynamicUserWhere(userIds, "u.id")); | ||
} | ||
|
||
@PreAuthorize("hasAnyAuthority('analytics_user')") | ||
@RequestMapping(value = "/report/hr/medianSync", method = RequestMethod.GET) | ||
public List<UserActivityDTO> getMedianSync(@RequestParam(value = "startDate", required = false) String startDate, | ||
@RequestParam(value = "endDate", required = false) String endDate, | ||
@RequestParam(value = "userIds", required = false, defaultValue = "") List<Long> userIds) { | ||
|
||
return reportRepository.generateMedianSync( | ||
OrgIdentityContextHolder.getDbSchema(), | ||
reportUtil.getDateSeries(startDate, endDate)); | ||
} | ||
|
||
@PreAuthorize("hasAnyAuthority('analytics_user')") | ||
@RequestMapping(value = "/report/hr/championUsers", method = RequestMethod.GET) | ||
public List<AggregateReportResult> getChampionUsers(@RequestParam(value = "startDate", required = false) String startDate, | ||
@RequestParam(value = "endDate", required = false) String endDate, | ||
@RequestParam(value = "userIds", required = false, defaultValue = "") List<Long> userIds) { | ||
return reportRepository.generateCompletedVisitsOnTimeByProportion( | ||
">= 0.5", | ||
OrgIdentityContextHolder.getDbSchema(), | ||
reportUtil.getDateDynamicWhere(startDate, endDate, "encounter_date_time"), | ||
reportUtil.getDynamicUserWhere(userIds, "u.id")); | ||
} | ||
|
||
@PreAuthorize("hasAnyAuthority('analytics_user')") | ||
@RequestMapping(value = "/report/hr/nonPerformingUsers", method = RequestMethod.GET) | ||
public List<AggregateReportResult> getNonPerformingUsers(@RequestParam(value = "startDate", required = false) String startDate, | ||
@RequestParam(value = "endDate", required = false) String endDate, | ||
@RequestParam(value = "userIds", required = false, defaultValue = "") List<Long> userIds) { | ||
return reportRepository.generateCompletedVisitsOnTimeByProportion( | ||
"<= 0.5", | ||
OrgIdentityContextHolder.getDbSchema(), | ||
reportUtil.getDateDynamicWhere(startDate, endDate, "encounter_date_time"), | ||
reportUtil.getDynamicUserWhere(userIds, "u.id") | ||
); | ||
} | ||
|
||
@PreAuthorize("hasAnyAuthority('analytics_user')") | ||
@RequestMapping(value = "/report/hr/mostCancelled", method = RequestMethod.GET) | ||
public List<AggregateReportResult> getUsersCancellingMostVisits(@RequestParam(value = "startDate", required = false) String startDate, | ||
@RequestParam(value = "endDate", required = false) String endDate, | ||
@RequestParam(value = "userIds", required = false, defaultValue = "") List<Long> userIds) { | ||
return reportRepository.generateUserCancellingMostVisits( | ||
OrgIdentityContextHolder.getDbSchema(), | ||
reportUtil.getDateDynamicWhere(startDate, endDate, "encounter_date_time"), | ||
reportUtil.getDynamicUserWhere(userIds, "u.id")); | ||
} | ||
|
||
|
||
} | ||
|
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
31 changes: 31 additions & 0 deletions
31
src/main/java/org/avniproject/etl/dto/AggregateReportResult.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,31 @@ | ||
package org.avniproject.etl.dto; | ||
|
||
public class AggregateReportResult { | ||
private String label; | ||
private Long value; | ||
private String id; | ||
|
||
public String getLabel() { | ||
return label; | ||
} | ||
|
||
public void setLabel(String label) { | ||
this.label = label; | ||
} | ||
|
||
public Long getValue() { | ||
return value; | ||
} | ||
|
||
public void setValue(Long value) { | ||
this.value = value; | ||
} | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public void setId(String id) { | ||
this.id = id; | ||
} | ||
} |
Oops, something went wrong.