1
|
package eu.dnetlib.usagestats.controllers;
|
2
|
|
3
|
import eu.dnetlib.usagestats.portal.CountryRepositories;
|
4
|
import eu.dnetlib.usagestats.portal.CountryUsageStats;
|
5
|
import eu.dnetlib.usagestats.portal.CountryUsageStatsAll;
|
6
|
import eu.dnetlib.usagestats.portal.MonthlyUsageStats;
|
7
|
import eu.dnetlib.usagestats.portal.TotalStats;
|
8
|
import eu.dnetlib.usagestats.portal.TotalStatsReposViewsDownloads;
|
9
|
import eu.dnetlib.usagestats.portal.UsageStats;
|
10
|
|
11
|
import eu.dnetlib.usagestats.services.UsageStatsService;
|
12
|
import java.util.List;
|
13
|
import org.apache.log4j.Logger;
|
14
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
15
|
import org.springframework.web.bind.annotation.PathVariable;
|
16
|
import org.springframework.web.bind.annotation.RequestMapping;
|
17
|
import org.springframework.web.bind.annotation.RequestMethod;
|
18
|
import org.springframework.web.bind.annotation.RestController;
|
19
|
|
20
|
|
21
|
@RestController
|
22
|
@CrossOrigin(methods = RequestMethod.GET, origins = "*")
|
23
|
public class UsageStatsController {
|
24
|
|
25
|
private final UsageStatsService usageStatsService;
|
26
|
|
27
|
private final Logger log = Logger.getLogger(this.getClass());
|
28
|
|
29
|
public UsageStatsController(UsageStatsService usageStatsService) {
|
30
|
this.usageStatsService = usageStatsService;
|
31
|
}
|
32
|
|
33
|
@RequestMapping(value = "/datasources/{datasourceId}/clicks")
|
34
|
public UsageStats getDatasourceClicks(@PathVariable(value = "datasourceId") String datasourceId) {
|
35
|
log.info("stats request for datasource: " + datasourceId);
|
36
|
return usageStatsService.getDatasourceClicks(datasourceId);
|
37
|
}
|
38
|
|
39
|
@RequestMapping(value = "/projects/{projectId}/clicks")
|
40
|
public UsageStats getProjectClicks(@PathVariable(value = "projectId") String projectId) {
|
41
|
log.info("stats request for project: " + projectId);
|
42
|
return usageStatsService.getProjectClicks(projectId);
|
43
|
}
|
44
|
|
45
|
@RequestMapping(value = "/monthlyusagestats")
|
46
|
public List<MonthlyUsageStats> getMonthlyUsageStats() {
|
47
|
log.info("stats request for months");
|
48
|
return usageStatsService.getMonthlyUsageStats();
|
49
|
}
|
50
|
|
51
|
@RequestMapping(value = "/countryusagestats")
|
52
|
public CountryUsageStatsAll getCountryUsageStatsAll() {
|
53
|
log.info("stats request for countries");
|
54
|
return usageStatsService.getCountryUsageStatsAll();
|
55
|
}
|
56
|
@RequestMapping(value = "/countryusagestats/{country}")
|
57
|
public CountryUsageStats getCountryUsageStats(@PathVariable(value = "country") String country) {
|
58
|
log.info("stats request for country "+country);
|
59
|
return usageStatsService.getCountryUsageStats(country);
|
60
|
}
|
61
|
|
62
|
@RequestMapping(value = "/countryrepositories")
|
63
|
public List<CountryRepositories> getCountryRepositories() {
|
64
|
log.info("stats request for countries/repos");
|
65
|
return usageStatsService.getCountryRepositories();
|
66
|
}
|
67
|
|
68
|
|
69
|
@RequestMapping(value = "/totals")
|
70
|
public TotalStats getTotalStats() {
|
71
|
log.info("total stats request");
|
72
|
return usageStatsService.getTotalStats();
|
73
|
}
|
74
|
|
75
|
@RequestMapping(value = "/monthlyusagestats/{datasourceId}")
|
76
|
public List<MonthlyUsageStats> getMonthlyUsageStatsForRepo(@PathVariable(value = "datasourceId") String datasourceId) {
|
77
|
log.info("stats request for datasource: " + datasourceId);
|
78
|
return usageStatsService.getMonthlyUsageStatsForRepo(datasourceId);
|
79
|
}
|
80
|
|
81
|
|
82
|
/*
|
83
|
@RequestMapping(value = "/organizations/{organizationId}/clicks")
|
84
|
public UsageStats getOrganizationClicks(@PathVariable(value = "organizationId") String organizationId) {
|
85
|
log.info("stats request for organization: " + organizationId);
|
86
|
return usageStatsService.getOrganizationClicks(organizationId);
|
87
|
}
|
88
|
*/
|
89
|
|
90
|
@RequestMapping(value = "/results/{resultId}/clicks")
|
91
|
public UsageStats getResultClicks(@PathVariable(value = "resultId") String resultId) {
|
92
|
log.info("stats request for result: " + resultId);
|
93
|
return usageStatsService.getResultClicks(resultId);
|
94
|
}
|
95
|
|
96
|
@RequestMapping(value = "/allmetrics")
|
97
|
public TotalStatsReposViewsDownloads getTotalStatsReposViewsDownloads() {
|
98
|
log.info("total stats request");
|
99
|
return usageStatsService.getTotalStatsReposViewsDownloads();
|
100
|
}
|
101
|
|
102
|
}
|