Skip to content

Commit

Permalink
Update Project.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenfree authored Jan 17, 2020
1 parent d7fddac commit e9a1734
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "CurricularAnalytics"
uuid = "593ffa3d-269e-5d81-88bc-c3b6809c35a6"
authors = ["Greg Heileman <[email protected]>", "Hayden Free <[email protected]>", "Orhan Abar <[email protected]>", "Will Thompson <[email protected]>"]
version = "0.6.3"
version = "0.6.4"

[deps]
Blink = "ad839575-38b3-5650-b840-f874b8c74a25"
Expand Down
44 changes: 44 additions & 0 deletions src/API.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#TODO - Include documentation in this file such that it builds to GitHub Pages

using Bukdu

struct RESTController <: ApplicationController
conn::Conn
end

function healthcheck(c::RESTController)
render(JSON, "Healthy")
end

function validate(c::RESTController)
@info :PAYLOAD (c.params.curriculum)
@info "Validating recieved degree plan..."
degreeplan = json_to_julia(c.params.curriculum)
result = isvalid_degree_plan(degreeplan)
if(result)
@info "Curriculum is valid."
else
@info "Curriculum is invalid"
end
render(JSON, julia_to_json(degreeplan))
end

function calculate_metrics(c::RESTController)
@info "Calculating degree plan metrics..."
degreeplan = json_to_julia(c.params.curriculum)
@info "Blocking factor: $(blocking_factor(degreeplan.curriculum))"
@info "Delay factor: $(delay_factor(degreeplan.curriculum))"
@info "Centrality: $(centrality(degreeplan.curriculum))"
@info "Complexity: $(complexity(degreeplan.curriculum))"
render(JSON, julia_to_json(degreeplan))
end

routes() do
get("/healthcheck", RESTController, healthcheck)
post("/validate", RESTController, validate)
post("/metrics", RESTController, calculate_metrics)
# create degree plan from curriculum
plug(Plug.Parsers, parsers=[:json])
end

Bukdu.start(8080, host="0.0.0.0")

0 comments on commit e9a1734

Please sign in to comment.