Skip to content

Commit

Permalink
Merge pull request #40 from antonin77/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
usfalami authored Feb 29, 2024
2 parents 5eb0221 + fe1557f commit cbad4ab
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/usf/trace/api/server/FilterCriteria.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ String toSql(Filters colname, Collection<Object> args, Collection<Integer> argTy
if(values.length == 1){
return " AND "+ sql;
}
return " AND (" + sql + " " + colname + "IN(" + Utils.nArg(values.length) + "))";//error
return " AND (" + sql + " " + colname + " IN(" + Utils.nArg(values.length) + "))";//error
}
args.addAll(Arrays.asList(values));
argTypes.addAll(Collections.nCopies(values.length, colname.getType()));
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/usf/trace/api/server/RequestDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -312,11 +312,11 @@ public Session getTreebyId(String id) {
" select ''::varchar as prnt, ? as chld " +
" union all " +
" select recusive.chld, E_API_REQ.CD_API " +
" from E_API_REQ , recusive " +
" from E_API_REQ, recusive " +
" where recusive.chld= E_API_REQ.CD_SES " +
") select distinct(chld) from recusive";

List<String> prntIds = template.query(query, (ResultSet rs, int rowNum) -> (rs.getString("chld")), id);
List<String> prntIds = template.query(query, (ResultSet rs, int rowNum) -> (rs.getString("chld")), id).stream().filter(Objects::nonNull).collect(toList());
List<Session> prntIncList = getIncomingRequestById(true, Exchange::new,prntIds.toArray(String[]::new));
List<MainSession> sessionList = getMainRequestById(true, Exchange::new, id);
if( sessionList != null && !sessionList.isEmpty()){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public ResponseEntity<MainSession> getMainRequestById(@PathVariable String id) {
return ResponseEntity.ok().cacheControl(CacheControl.maxAge(1, TimeUnit.DAYS)).body(requireSingle(dao.getMainRequestById(true, ApiRequest::new, id)));
}

@GetMapping("session/api/{id}/out")
@GetMapping("session/request/{id}/out")
public ApiRequest getOutcomingRequestById(@PathVariable String id) {
return dao.getOutcomingRequestById(id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import java.io.IOException;
import java.util.List;
import java.util.stream.Stream;

import javax.servlet.http.HttpServletResponse;

Expand All @@ -16,11 +17,13 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.usf.jquery.core.DynamicModel;
import org.usf.jquery.core.RequestQueryBuilder;
import org.usf.jquery.core.*;
import org.usf.jquery.web.RequestQueryParam;

import lombok.RequiredArgsConstructor;
import org.usf.trace.api.server.config.DataConstants;
import org.usf.trace.api.server.config.TraceApiColumn;
import org.usf.trace.api.server.config.TraceApiTable;

@CrossOrigin
@RestController
Expand All @@ -31,17 +34,24 @@ public class PerformanceStatsController {
private final JdbcTemplate template;

@GetMapping(value="incoming/request", produces = APPLICATION_JSON_VALUE)
public List<DynamicModel> stats(
public List<DynamicModel> request(
@RequestQueryParam(name = "request", defaultColumns = "count") RequestQueryBuilder query) {
return usingSpringJdbc(query);
}

@GetMapping(value="session", produces = APPLICATION_JSON_VALUE)
public List<DynamicModel> session(
@RequestQueryParam(name = "session", defaultColumns = "count") RequestQueryBuilder query) {
return usingSpringJdbc(query);
}

@GetMapping(value="environment", produces = APPLICATION_JSON_VALUE)
public List<DynamicModel> environment(
@RequestQueryParam(name = "request", defaultColumns = "environement") RequestQueryBuilder query
) {
return usingSpringJdbc(query.distinct());
}

private List<DynamicModel> usingSpringJdbc(RequestQueryBuilder req) {
var query = req.build();
return template.query(query.getQuery(), query.defaultMapper()::map, query.getParams());
Expand Down

0 comments on commit cbad4ab

Please sign in to comment.