-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Application usage statistics #2387
Changes from 1 commit
3981341
05e64a5
53e27a6
8e28b98
1fe7db0
462d81d
01c0d51
af3f682
4fe2f04
3233ba3
1a431c3
038a60b
32c98a7
24ebe0c
82a3ac9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,10 +10,11 @@ | |
import org.ohdsi.webapi.statistic.service.StatisticService; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Controller; | ||
|
||
import javax.ws.rs.Consumes; | ||
import javax.ws.rs.NotFoundException; | ||
import javax.ws.rs.POST; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
|
@@ -30,12 +31,14 @@ | |
|
||
@Controller | ||
@Path("/statistic/") | ||
@ConditionalOnProperty(value = "audit.trail.enabled", havingValue = "true") | ||
public class StatisticController { | ||
|
||
private static final Logger log = LoggerFactory.getLogger(StatisticController.class); | ||
|
||
private StatisticService service; | ||
|
||
@Value("${audit.trail.enabled}") | ||
private boolean auditTrailEnabled; | ||
|
||
public enum ResponseFormat { | ||
CSV, JSON | ||
|
@@ -70,6 +73,9 @@ public StatisticController(StatisticService service) { | |
@Produces(MediaType.APPLICATION_JSON) | ||
@Consumes(MediaType.APPLICATION_JSON) | ||
public Response executionStatistics(ExecutionStatisticsRequest executionStatisticsRequest) { | ||
if (!auditTrailEnabled) { | ||
throw new NotFoundException("Audit Trail functionality should be enabled (audit.trail.enabled) to serve this endpoint"); | ||
} | ||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); | ||
boolean showUserInformation = executionStatisticsRequest.isShowUserInformation(); | ||
|
||
|
@@ -92,6 +98,9 @@ public Response executionStatistics(ExecutionStatisticsRequest executionStatisti | |
@Produces(MediaType.APPLICATION_JSON) | ||
@Consumes(MediaType.APPLICATION_JSON) | ||
public Response accessStatistics(AccessTrendsStatisticsRequest accessTrendsStatisticsRequest) { | ||
if (!auditTrailEnabled) { | ||
throw new NotFoundException("Audit Trail functionality should be enabled (audit.trail.enabled) to serve this endpoint"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NotFound results in a 404, correct? We said that it would be confusing if someone looked at an api and attempted to call an endpoint and it was not found. I think we mentioned raising an error, such that it could return an HTTP 500 or some other HTTP code that represents an error other than 'not found'? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I misread your passage, corrected to the internal server error |
||
} | ||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); | ||
boolean showUserInformation = accessTrendsStatisticsRequest.isShowUserInformation(); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both CSV and JSON output formats should be supported