Skip to content

Commit

Permalink
Bug Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MichailVlasopoulos committed Jan 26, 2021
1 parent 5c1ff53 commit e24839a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,9 @@ public interface RequestResultsRepository extends JpaRepository<RequestResults,I
@Transactional
@Query(value = "UPDATE Requests_Results SET request_status=?1,results=?2 WHERE request_id=?3",nativeQuery = true)
Integer updateRequest_Accept(String request_status, String results,int requestId);

@Modifying(clearAutomatically = true)
@Transactional
@Query(value = "UPDATE Request_Results SET request_status=?1 WHERE request_id=?2",nativeQuery = true)
Integer updateRequest_Deny(String request_status,int request_id);
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class AdminService {
private final static String cancelPremiumRequestType = "Cancel Premium";
private final static String generalChampionStatsType = "General Champion Stats";

private final static String API_KEY = "RGAPI-4037b92b-0756-43e6-9e7b-33edaac190aa";
private final static String API_KEY = "RGAPI-004f6b79-5217-4f61-a61d-d294dba386ba";

public Iterable<User> getAllUsers() {
return userRepository.findAll();
Expand All @@ -59,17 +59,19 @@ public JSONObject acceptRequest(int requestId) throws JSONException,AdminService
//get the request
Request request = requestRepository.findRequestByRequest_id(requestId);
RequestResults requestResults = requestResultsRepository.findRequestResultsByRequest_id(requestId);
String status = requestResults.getRequest_status();

//TODO CHECK FOR REQEUST STATUS = DENIED
if (requestResults.getRequest_status().equals("ACCEPTED"))
return JsonUtils.stringToJsonObject("Status", "Failed: This request has been accepted");
if (status.equals("ACCEPTED") || status.equals("DENIED"))
return JsonUtils.stringToJsonObject("Status", "Failed: This request has been: "+status);

//get the user
User user = userRepository.findById(request.getUserid());
String summonerName = user.getSummoner_name();

//call RITO api - find summoner's encrypted ID'S
String url = UrlUtils.getSummonersURL(summonerName,API_KEY);
if (url==null)
return JsonUtils.stringToJsonObject("Status", "Failed");

JSONObject response = ResultUtils.getSummonerUrlResponse(url);
if (response==null)
Expand Down Expand Up @@ -139,7 +141,7 @@ public JSONObject denyRequest(int requestId) throws JSONException,AdminServiceEx
if (requestResults.getRequest_status().equals("DENIED"))
return JsonUtils.stringToJsonObject("Status", "Failed: This request has been denied");

requestRepository.updateRequest_Deny("DENIED",requestId);
requestResultsRepository.updateRequest_Deny("DENIED",requestId);
return JsonUtils.stringToJsonObject("Status", "Successful");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class UserService {

private Authentication authentication;
private String username;
private final static String API_KEY = "RGAPI-4037b92b-0756-43e6-9e7b-33edaac190aa";
private final static String API_KEY = "RGAPI-004f6b79-5217-4f61-a61d-d294dba386ba";

private final static String MatchHistoryRequestType = "Match History";
private final static String MyProfileRequestType = "My Profile";
Expand Down Expand Up @@ -204,7 +204,10 @@ public String getMyRequests(String requestStatus) throws JSONException, AdminSer
RequestResults requestResults;
RequestResults tempResults = new RequestResults();

//for each request
for (Request request:requests) {

//get request results
requestResults = requestResultsRepository.findRequestResultsByRequest_id(request.getRequest_id());

String status = requestResults.getRequest_status();
Expand Down

0 comments on commit e24839a

Please sign in to comment.