metrics change
This commit is contained in:
parent
09d6528f8f
commit
903026e2c2
|
@ -22,22 +22,15 @@ public class AboutController {
|
|||
|
||||
private Environment environment;
|
||||
private MaterialManager materialManager;
|
||||
private final MetricsManager metricsManager;
|
||||
|
||||
@Autowired
|
||||
public AboutController(Environment environment, MaterialManager materialManager, MetricsManager metricsManager) {
|
||||
this.environment = environment;
|
||||
this.materialManager = materialManager;
|
||||
this.metricsManager = metricsManager;
|
||||
}
|
||||
|
||||
@RequestMapping(path = "{lang}", method = RequestMethod.GET )
|
||||
public ResponseEntity<byte[]> getAbout(@PathVariable(name = "lang") String lang) throws IOException {
|
||||
// long files = 0;
|
||||
// try (Stream<Path> paths = Files.list(Paths.get(Objects.requireNonNull(this.environment.getProperty("about.path"))))) {
|
||||
// files = paths.count();
|
||||
// }
|
||||
// metricsManager.calculateValue(MetricNames.LANGUAGES, (int) files, null);
|
||||
try (Stream<Path> paths = Files.walk(Paths.get(Objects.requireNonNull(this.environment.getProperty("about.path"))))) {
|
||||
return this.materialManager.getResponseEntity(lang, paths);
|
||||
}
|
||||
|
|
|
@ -21,22 +21,15 @@ public class FaqController {
|
|||
|
||||
private Environment environment;
|
||||
private MaterialManager materialManager;
|
||||
private final MetricsManager metricsManager;
|
||||
|
||||
@Autowired
|
||||
public FaqController(Environment environment, MaterialManager materialManager, MetricsManager metricsManager) {
|
||||
this.environment = environment;
|
||||
this.materialManager = materialManager;
|
||||
this.metricsManager = metricsManager;
|
||||
}
|
||||
|
||||
@RequestMapping(path = "{lang}", method = RequestMethod.GET )
|
||||
public ResponseEntity<byte[]> getFaq(@PathVariable(name = "lang") String lang) throws IOException {
|
||||
// long files = 0;
|
||||
// try (Stream<Path> paths = Files.list(Paths.get(Objects.requireNonNull(this.environment.getProperty("faq.path"))))) {
|
||||
// files = paths.count();
|
||||
// }
|
||||
// metricsManager.calculateValue(MetricNames.LANGUAGES, (int) files, null);
|
||||
try (Stream<Path> paths = Files.walk(Paths.get(Objects.requireNonNull(this.environment.getProperty("faq.path"))))) {
|
||||
return this.materialManager.getResponseEntity(lang, paths);
|
||||
}
|
||||
|
|
|
@ -21,22 +21,15 @@ public class GlossaryController {
|
|||
|
||||
private Environment environment;
|
||||
private MaterialManager materialManager;
|
||||
private final MetricsManager metricsManager;
|
||||
|
||||
@Autowired
|
||||
public GlossaryController(Environment environment, MaterialManager materialManager, MetricsManager metricsManager) {
|
||||
this.environment = environment;
|
||||
this.materialManager = materialManager;
|
||||
this.metricsManager = metricsManager;
|
||||
}
|
||||
|
||||
@RequestMapping(path = "{lang}", method = RequestMethod.GET )
|
||||
public ResponseEntity<byte[]> getGlossary(@PathVariable(name = "lang") String lang) throws IOException {
|
||||
// long files = 0;
|
||||
// try (Stream<Path> paths = Files.list(Paths.get(Objects.requireNonNull(this.environment.getProperty("glossary.path"))))) {
|
||||
// files = paths.count();
|
||||
// }
|
||||
// metricsManager.calculateValue(MetricNames.LANGUAGES, (int) files, null);
|
||||
try (Stream<Path> paths = Files.walk(Paths.get(Objects.requireNonNull(this.environment.getProperty("glossary.path"))))) {
|
||||
return this.materialManager.getResponseEntity(lang, paths);
|
||||
}
|
||||
|
|
|
@ -21,22 +21,15 @@ public class TermsOfServiceController {
|
|||
|
||||
private Environment environment;
|
||||
private MaterialManager materialManager;
|
||||
private final MetricsManager metricsManager;
|
||||
|
||||
@Autowired
|
||||
public TermsOfServiceController(Environment environment, MaterialManager materialManager, MetricsManager metricsManager) {
|
||||
this.environment = environment;
|
||||
this.materialManager = materialManager;
|
||||
this.metricsManager = metricsManager;
|
||||
}
|
||||
|
||||
@RequestMapping(path = "{lang}", method = RequestMethod.GET )
|
||||
public ResponseEntity<byte[]> getTermsOfService(@PathVariable(name = "lang") String lang) throws IOException {
|
||||
// long files = 0;
|
||||
// try (Stream<Path> paths = Files.list(Paths.get(Objects.requireNonNull(this.environment.getProperty("termsofservice.path"))))) {
|
||||
// files = paths.count();
|
||||
// }
|
||||
// metricsManager.calculateValue(MetricNames.LANGUAGES, (int) files, null);
|
||||
try (Stream<Path> paths = Files.walk(Paths.get(Objects.requireNonNull(this.environment.getProperty("termsofservice.path"))))) {
|
||||
return this.materialManager.getResponseEntity(lang, paths);
|
||||
}
|
||||
|
|
|
@ -34,22 +34,15 @@ public class UserGuideController {
|
|||
|
||||
private Environment environment;
|
||||
private MaterialManager materialManager;
|
||||
private final MetricsManager metricsManager;
|
||||
|
||||
@Autowired
|
||||
public UserGuideController(Environment environment, MaterialManager materialManager, MetricsManager metricsManager) {
|
||||
this.environment = environment;
|
||||
this.materialManager = materialManager;
|
||||
this.metricsManager = metricsManager;
|
||||
}
|
||||
|
||||
@RequestMapping(path = "{lang}", method = RequestMethod.GET )
|
||||
public ResponseEntity<byte[]> getUserGuide(@PathVariable(name = "lang") String lang) throws IOException {
|
||||
long files = 0;
|
||||
try (Stream<Path> paths = Files.list(Paths.get(Objects.requireNonNull(this.environment.getProperty("userguide.path"))))) {
|
||||
files = paths.count();
|
||||
}
|
||||
metricsManager.calculateValue(MetricNames.LANGUAGES, (int) files, null);
|
||||
try (Stream<Path> paths = Files.walk(Paths.get(Objects.requireNonNull(this.environment.getProperty("userguide.path"))))) {
|
||||
return this.materialManager.getResponseEntity(lang, paths);
|
||||
}
|
||||
|
|
|
@ -180,6 +180,8 @@ public class MetricsManager {
|
|||
try (Stream<Path> paths = Files.list(Paths.get(Objects.requireNonNull(this.environment.getProperty("userguide.path"))))) {
|
||||
long files = paths.count();
|
||||
calculateValue(MetricNames.LANGUAGES, (int) files, null);
|
||||
} catch (Exception e) {
|
||||
logger.error("Could not calculate languages.");
|
||||
}
|
||||
|
||||
calculateValue(MetricNames.INSTALLATIONS, 1, null);
|
||||
|
|
Loading…
Reference in New Issue