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
13 changes: 6 additions & 7 deletions FEEDBACK.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# Feedback

1. Your team:
2. Name of each individual participating:
3. How many unit tests were you able to pass?
1. Your team: Last Hurrah
2. Name of each individual participating: Levi Bottomley
3. How many unit tests were you able to pass? All
4. Document and describe any enhancements included to help the judges properly grade your submission.
- Example One
- Example Two
- Example Three
- Methods use native Javascript Filters and Classes to make it so overall code base remains light.
- Began adding and API Implementation

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

This form can also be emailed to [codingcompetition@statefarm.com](mailto:codingcompetition@statefarm.com). Just make sure that you include a link to your GitHub pull requests.
23 changes: 23 additions & 0 deletions nodejs/application.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
const SimpleDataTool = require("./simpleDataTool");
const api = require('lambda-api')();
const {
getAgent,
getClaim,
getHandler,
getDisaster,
getClaimDensity,
getTopMonths
} = require("./handler.js");

console.log("I'm working");

const controller = new SimpleDataTool();
controller.loadSimpleModels();

api.get("/health", async (req, res) => { res.sendStatus(200) });

api.get("/agent/:id", getAgent);
api.get("/claim/:id", getClaim);
api.get("/handler/:id", getHandler);
api.get("/disaster/:id", getDisaster);

api.get("/stats/claim/top_months", getTopMonths);
api.get("/stats/disaster/claim_density/:id", getClaimDensity);

exports.handler = async (event, context) => {
return await api.run(event, context)
}
140 changes: 140 additions & 0 deletions nodejs/handler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
const SimpleDataTool = require("./simpleDataTool");
const dataTool = new SimpleDataTool();



const getAgent = async (req, res) => {
try {
let data = dataTool.getAgent(req.params.id);
if (data.length != 1) {
res.status(500).send({
success: false,
agent: null
})
} else {
res.status(200).send({
success: true,
agent: data[0]
})
}
} catch (err) {
res.status(500).send({
success: false,
density: -1,
message: "Error Invalid Query"
})
}
}

const getClaim = async (req, res) => {
try {
let data = dataTool.getAgent(req.params.id);
if (data.length != 1) {
res.status(500).send({
success: false,
disaster: null
})
} else {
res.status(200).send({
success: true,
claim: data[0]
})
}
} catch (err) {
res.status(500).send({
success: false,
density: -1,
message: "Error Invalid Query"
})
}

}
const getHandler = async (req, res) => {
try {
let data = dataTool.getClaimHandler(req.params.id);
if (data.length != 1) {
res.status(500).send({
success: false,
handler: null
})
} else {
res.status(200).send({
success: true,
handler: data[0]
})
}
} catch (err) {
res.status(500).send({
success: false,
density: -1,
message: "Error Invalid Query"
})
}

}
const getDisaster = async (req, res) => {
try {
let data = dataTool.getDisaster(req.params.id);
if (data.length != 1) {
res.status(500).send({
success: false,
disaster: null
})
} else {
res.status(200).send({
success: true,
disaster: data[0]
})
}
} catch (err) {
res.status(500).send({
success: false,
density: -1,
message: "Error Invalid Query"
})
}

}

const getTopMonths = async (req, res) => {
try {
let data = dataTool.getTopThreeMonthsWithHighestNumOfClaimsDesc();

res.status(200).send({
success: true,
topMonths: data
})
} catch (err) {
res.status(500).send({
success: false,
density: -1,
message: "Error Invalid Query"
})
}

}

const getClaimDensity = async (req, res) => {
try {
let data = dataTool.calculateDisasterClaimDensity();
res.status(200).send({

})
} catch (err) {
res.status(500).send({
success: false,
density: -1,
message: "Error Invalid Query"
})
}
}



module.exports = {
getAgent,
getClaim,
getHandler,
getDisaster,
getTopMonths,
};
Loading