Skip to content
Snippets Groups Projects
Commit 0eb6d557 authored by Mirco Nasuti's avatar Mirco Nasuti
Browse files

second datasource has to be fixed but almost done

parent 10138179
No related branches found
No related tags found
No related merge requests found
......@@ -26,7 +26,7 @@ public class PersistenceConfiguration {
DataSource dataSource;
@Autowired
DataSource variablesDatasource;
DataSource variablesDatasource; // TODO: Fix this problem
@Bean
@DependsOn("flyway")
......
......@@ -14,10 +14,13 @@ import io.swagger.annotations.ApiResponses;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.sql.DataSource;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
@RestController
......@@ -33,6 +36,9 @@ public class StatsApi {
@Autowired
ArticleRepository articleRepository;
@Autowired
DataSource variablesDatasource;
@ApiOperation(value = "Get general statistics", response = GeneralStats.class)
@ApiResponses(value = {@ApiResponse(code = 200, message = "Found"), @ApiResponse(code = 404, message = "Not found") })
......@@ -44,9 +50,17 @@ public class StatsApi {
stats.setUsers(userRepository.count());
stats.setArticles(articleRepository.count());
stats.setVariables(0L); // TODO: compute from adni_merge DB
stats.setVariables(countVariables());
return ResponseEntity.ok(stats);
}
private Long countVariables()
{
JdbcTemplate db = new JdbcTemplate(variablesDatasource);
LOGGER.warn("TEST DB : " + db.queryForObject("select count(*) from information_schema.tables", Long.class)); // This is a test
Long count = db.queryForObject("select count(*) from adni_merge", Long.class); // TODO: compute from adni_merge DB
return count;
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment