Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"java.configuration.updateBuildConfiguration": "interactive"
}
37 changes: 31 additions & 6 deletions FEEDBACK.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,38 @@
# Feedback

1. Your team:
2. Name of each individual participating:
3. How many unit tests were you able to pass?
1. Your team: Preston Roesslet
2. Name of each individual participating: Preston Roesslet
3. How many unit tests were you able to pass? 13 - However, I believe that I would pass all 14 of them if Issue #9 had been resolved. At the time of my submission, Issue #9 had yet to be resolved, so I wasn't sure how to move forward with Test Set 3 - Test 10
4. Document and describe any enhancements included to help the judges properly grade your submission.
- Example One
- Example Two
- Example Three

I implemented a REST Api to interact with the data from the problem set. I utilized Spring Boot. The Spring Boot application is initialized in the RestApi class. I then created all of the endpoints inside of the ApiController.java file.

To run the Spring Boot application, run `mvn spring-boot:run`. The required packages have already been added to my pom.xml file. It runs on localhost:8080 and below is a list of the available endpoints:

- /numberClosedClaims - returns the number of claims where the status is closed
- /numClaims/{id} - returns the number of claims associated with the given claim handler ID
- /numDisasters/{state} - returns the number of disasters in the given state
- /disasterTotalCost/{id} - returns the total claim cost for the given disaster ID
- /averageClaimCost/{id} - returns the average claim cost for the given claim handler ID
- /stateWithMostDisasters - returns the state with the highest number of disasters
- /stateWithLeastDisasters - returns the state with the highest number of disasters
- /mostSpokenLanguage/{state} - returns the language spoken most by claim handlers in the given state
- /numOpenClaims/{id}/{minSeverity} - returns the number of open claims for the given agent ID and above the given minimum severity
- /numDistastersDeclaredAfterEndDate - returns the number of disasters where it was declared after it ended
- /agentsTotalClaimCost - returns a map of agent ID's and their total claim cost
- /disasterClaimDensity/{id} - returns the density of the given disaster ID based on the number of claims and the impact radius

I also implemented some additional methods which can be utilized with the following endpoints:

- /agents - returns a list of all agents
- /claimHandlers - returns a list of all agents

This could be further extended to include persistent data through a database rather than just json files, or even creating a front end to view/edit the data. However, given the time constraints for this competition, these were not feasible to implement.

5. Any feedback for the coding competition? Things you would like to see in future events?

One thing in particular that I think could be better is ensuring that the test cases and skeleton code are bug free. While I know that programming certainly comes along with bugs, it felt as though there were many issues, some of which weren't being resolved until towards the end of the competition. This made it difficult to complete all tasks in an efficient manner and I could not complete one of the test cases at all prior to submission due to this.

Overall though this was a very fun competition!

This form can also be emailed to [[email protected]](mailto:[email protected]). Just make sure that you include a link to your GitHub pull requests.
39 changes: 38 additions & 1 deletion java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,44 @@
<artifactId>gson</artifactId>
<version>2.10.1</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>3.1.4</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<version>3.1.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.vintage/junit-vintage-engine -->
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.10.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.9</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.9</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>3.1.4</version>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package com.statefarm.codingcompetition;

import java.util.List;
import java.util.Map;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import com.statefarm.codingcompetition.simpledatatool.controller.SimpleDataTool;
import com.statefarm.codingcompetition.simpledatatool.model.Agent;
import com.statefarm.codingcompetition.simpledatatool.model.Claim;
import com.statefarm.codingcompetition.simpledatatool.model.ClaimHandler;
import com.statefarm.codingcompetition.simpledatatool.model.Disaster;

@RestController
public class ApiController {

SimpleDataTool dataService = new SimpleDataTool();


@GetMapping("/numberClosedClaims")
public int getNumClosedClaims() {
return dataService.getNumClosedClaims();
}

@GetMapping("/numClaims/{id}")
public int getNumClaims(@PathVariable("id") int id) {
return dataService.getNumClaimsForClaimHandlerId(id);
}

@GetMapping("/numDisasters/{state}")
public int getNumDisasters(@PathVariable("state") String state) {
return dataService.getNumDisastersForState(state);
}

@GetMapping("/disasterTotalCost/{id}")
public Double getDisasterTotalCost(@PathVariable("id") int id) {
return dataService.getTotalClaimCostForDisaster(id);
}

@GetMapping("/averageClaimCost/{id}")
public Double getAverageClaimCost(@PathVariable("id") int id) {
return dataService.getAverageClaimCostforClaimHandler(id);
}

@GetMapping("/stateWithMostDisasters")
public String getStateWithMostDisasters() {
return dataService.getStateWithTheMostDisasters();
}

@GetMapping("/stateWithLeastDisasters")
public String getStateWithLeastDisasters() {
return dataService.getStateWithTheLeastDisasters();
}

@GetMapping("/mostSpokenLanguage/{state}")
public String getMostSpokenLanguage(@PathVariable("state") String state) {
return dataService.getMostSpokenAgentLanguageByState(state);
}

@GetMapping("/numOpenClaims/{id}/{minSeverity}")
public int getNumOpenClaims(@PathVariable("id") int id, @PathVariable("minSeverity") int minSeverity) {
return dataService.getNumOfOpenClaimsForAgentAndSeverity(id, minSeverity);
}

@GetMapping("/numDistastersDeclaredAfterEndDate")
public int getNumDistastersDeclaredAfterEndDate() {
return dataService.getNumDisastersDeclaredAfterEndDate();
}

@GetMapping("/agentsTotalClaimCost")
public Map<Integer, Float> getAgentsTotalClaimCost() {
return dataService.buildMapOfAgentsToTotalClaimCost();
}

@GetMapping("/disasterClaimDensity/{id}")
public Float getDisasterClaimDensity(@PathVariable("id") int id) {
return dataService.calculateDisasterClaimDensity(id);
}

// Additional endpoints
@GetMapping("/agents")
public List<Agent> getAgents() {
return dataService.getAgents();
}

@GetMapping("/claimHandlers")
public List<ClaimHandler> getClaimHandlers() {
return dataService.getClaimHandlers();
}
}

11 changes: 11 additions & 0 deletions java/src/main/java/com/statefarm/codingcompetition/RestApi.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.statefarm.codingcompetition;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class RestApi {
public static void main(String[] args) {
SpringApplication.run(RestApi.class, args);
}
}
Loading