Skip to content

Commit

Permalink
Pearson merges
Browse files Browse the repository at this point in the history
  • Loading branch information
opoudjis committed Mar 27, 2017
2 parents 702c3b3 + ead68dd commit cd556bf
Show file tree
Hide file tree
Showing 131 changed files with 26,170 additions and 232 deletions.
18 changes: 14 additions & 4 deletions app/naprr/naprr.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ import (
"os"
// "os/exec"
// "os/signal"
// "runtime"
"runtime"
// "time"
)

var rewrite = flag.Bool("rewrite", false, "rewrite regenerates all reports without re-loading data")
var webonly = flag.Bool("webonly", false, "just launch web data explorer")

func main() {

Expand All @@ -36,6 +37,7 @@ func main() {

di := naprr.NewDataIngest()
di.Run()
di.RunCSV()

log.Println("Generating report data...")
rb := naprr.NewReportBuilder()
Expand All @@ -46,9 +48,14 @@ func main() {
rw := naprr.NewReportWriter()
rw.Run()

log.Println("Done.")
log.Println("Ingest and report writing complete.")

// runtime.Goexit()
log.Println("Starting web data browser server.")

rrs := naprr.NewResultsReportingServer()
rrs.Run()

runtime.Goexit()
}

func clearNSSWorkingDirectory() {
Expand All @@ -75,7 +82,10 @@ func launchNatsStreamingServer() *server.StanServer {
stanOpts.FilestoreDir = "nss"
// stanOpts.Debug = true

ss := server.RunServerWithOpts(stanOpts, nil)
nOpts := server.DefaultNatsServerOptions
nOpts.Port = 5222

ss := server.RunServerWithOpts(stanOpts, &nOpts)

return ss

Expand Down
116 changes: 116 additions & 0 deletions app/naprr/naprr_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
package main

import (
"github.com/nsip/nias2/naprr"
//"log"
"bufio"
"os"
"path/filepath"
"sort"
"strings"
"testing"
)

func errcheck(t *testing.T, err error) {
if err != nil {
t.Fatalf("Error %s", err)
}
}

func TestFileLoadAndReport(t *testing.T) {

s, _ := os.Getwd()
err := os.RemoveAll(filepath.Join(s, "out"))
if _, err := os.Stat("./out/codeframe.csv"); err == nil {
t.Fatalf("codeframe.csv not cleared")
}
err = os.MkdirAll(filepath.Join(s, "out"), 0777)
errcheck(t, err)

filename := "../../unit_test_files/minimaster.xml.zip"
clearNSSWorkingDirectory()
di := naprr.NewDataIngest()
di.RunSynchronous(filename)
rb := naprr.NewReportBuilder()
rb.Run()
rw := naprr.NewReportWriter()
rw.Run()

if _, err := os.Stat("./out/codeframe.csv"); os.IsNotExist(err) {
t.Fatalf("codeframe.csv not generated")
}
if _, err := os.Stat("./out/codeframe_writing.csv"); os.IsNotExist(err) {
t.Fatalf("codeframe_writing.csv not generated")
}
if _, err := os.Stat("./out/domain_scores.csv"); os.IsNotExist(err) {
t.Fatalf("domain_scores.csv not generated")
}
if _, err := os.Stat("./out/participation.csv"); os.IsNotExist(err) {
t.Fatalf("participation.csv not generated")
}
if _, err := os.Stat("./out/score_summary.csv"); os.IsNotExist(err) {
t.Fatalf("score_summary.csv not generated")
}
if _, err := os.Stat("./out/21212/domain_scores.csv"); os.IsNotExist(err) {
t.Fatalf("21212/domain_scores.csv not generated")
}
}

func TestReportFiles(t *testing.T) {
filescompare(t, "./out/codeframe.csv", "../../unit_test_files/naprr_out/codeframe.csv")
filescompare(t, "./out/codeframe_writing.csv", "../../unit_test_files/naprr_out/codeframe_writing.csv")
filescompare(t, "./out/domain_scores.csv", "../../unit_test_files/naprr_out/domain_scores.csv")
filescompare(t, "./out/participation.csv", "../../unit_test_files/naprr_out/participation.csv")
filescompare(t, "./out/score_summary.csv", "../../unit_test_files/naprr_out/score_summary.csv")
filescompare(t, "./out/score_summary.csv", "../../unit_test_files/naprr_out/score_summary.csv")
filescompare(t, "./out/21212/domain_scores.csv", "../../unit_test_files/naprr_out/21212/domain_scores.csv")
filescompare(t, "./out/21212/participation.csv", "../../unit_test_files/naprr_out/21212/participation.csv")
filescompare(t, "./out/21212/score_summary.csv", "../../unit_test_files/naprr_out/21212/score_summary.csv")
filescompare(t, "./out/21213/domain_scores.csv", "../../unit_test_files/naprr_out/21213/domain_scores.csv")
filescompare(t, "./out/21213/participation.csv", "../../unit_test_files/naprr_out/21213/participation.csv")
filescompare(t, "./out/21213/score_summary.csv", "../../unit_test_files/naprr_out/21213/score_summary.csv")
}

func filescompare(t *testing.T, file1name string, file2name string) {
file1, err := readLines(file1name)
errcheck(t, err)
file2, err := readLines(file2name)
errcheck(t, err)
if len(file1) != len(file2) {
t.Fatalf("%s does not have the number of lines (%d, %d)\n%v\n%v\n", file1name, len(file1), len(file2), file1, file2)
}
sort.Strings(file1)
sort.Strings(file2)
for i := 0; i < len(file1); i++ {
if !strings.EqualFold(file1[i], file2[i]) {
t.Fatalf("Line in %s is not the expected value:\nExpected: %s\nActual : %s\n", file1name, file2[i], file1[i])
}
}
}

// readLines reads a whole file into memory
// and returns a slice of its lines.
func readLines(path string) ([]string, error) {
file, err := os.Open(path)
if err != nil {
return nil, err
}
defer file.Close()

var lines []string
scanner := bufio.NewScanner(file)
for scanner.Scan() {
lines = append(lines, scanner.Text())
}
return lines, scanner.Err()
}

func TestMain(m *testing.M) {
clearNSSWorkingDirectory()
/* clear out the out directory */
os.RemoveAll("./out/*/*")
os.RemoveAll("./out/*.csv")
ss := launchNatsStreamingServer()
defer ss.Shutdown()
os.Exit(m.Run())
}
225 changes: 225 additions & 0 deletions app/naprr/public/css/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
.container {
max-width: 900px; }
.header {
margin-top: 6rem;
text-align: center; }
.value-prop {
margin-top: 1rem; }
.value-props {
margin-top: 4rem;
margin-bottom: 4rem; }
.docs-header {
text-transform: uppercase;
font-size: 1.4rem;
letter-spacing: .2rem;
font-weight: 600; }
.docs-section {
border-top: 1px solid #eee;
padding: 4rem 0;
margin-bottom: 0;}
.value-img {
display: block;
text-align: center;
margin: 2.5rem auto 0; }
.example-grid .column,
.example-grid .columns {
background: #EEE;
text-align: center;
border-radius: 4px;
font-size: 1rem;
text-transform: uppercase;
height: 30px;
line-height: 30px;
margin-bottom: .75rem;
font-weight: 600;
letter-spacing: .1rem; }
.docs-example .row,
.docs-example.row,
.docs-example form {
margin-bottom: 0; }
.docs-example h1,
.docs-example h2,
.docs-example h3,
.docs-example h4,
.docs-example h5,
.docs-example h6 {
margin-bottom: 1rem; }
.heading-font-size {
font-size: 1.2rem;
color: #999;
letter-spacing: normal; }
.code-example {
margin-top: 1.5rem;
margin-bottom: 0; }
.code-example-body {
white-space: pre;
word-wrap: break-word }
.example {
position: relative;
margin-top: 4rem; }
.example-header {
font-weight: 600;
margin-top: 1.5rem;
margin-bottom: .5rem; }
.example-description {
margin-bottom: 1.5rem; }
.example-screenshot-wrapper {
display: block;
position: relative;
overflow: hidden;
border-radius: 6px;
border: 1px solid #eee;
height: 250px; }
.example-screenshot {
width: 100%;
height: auto; }
.example-screenshot.coming-soon {
width: auto;
position: absolute;
background: #eee;
top: 5px;
right: 5px;
bottom: 5px;
left: 5px; }
.navbar {
display: none; }

/* Larger than phone */
@media (min-width: 550px) {
.header {
margin-top: 18rem; }
.value-props {
margin-top: 9rem;
margin-bottom: 7rem; }
.value-img {
margin-bottom: 1rem; }
.example-grid .column,
.example-grid .columns {
margin-bottom: 1.5rem; }
.docs-section {
padding: 6rem 0; }
.example-send-yourself-copy {
float: right;
margin-top: 12px; }
.example-screenshot-wrapper {
position: absolute;
width: 48%;
height: 100%;
left: 0;
max-height: none; }
}

/* Larger than tablet */
@media (min-width: 750px) {
/* Navbar */
.navbar + .docs-section {
border-top-width: 0; }
.navbar,
.navbar-spacer {
display: block;
width: 100%;
height: 6.5rem;
background: #fff;
z-index: 99;
border-top: 1px solid #eee;
border-bottom: 1px solid #eee; }
.navbar-spacer {
display: none; }
.navbar > .container {
width: 100%; }
.navbar-list {
list-style: none;
margin-bottom: 0; }
.navbar-item {
position: relative;
float: left;
margin-bottom: 0; }
.navbar-link {
text-transform: uppercase;
font-size: 11px;
font-weight: 600;
letter-spacing: .2rem;
margin-right: 35px;
text-decoration: none;
line-height: 6.5rem;
color: #222; }
.navbar-link.active {
color: #33C3F0; }
.has-docked-nav .navbar {
position: fixed;
top: 0;
left: 0; }
.has-docked-nav .navbar-spacer {
display: block; }
/* Re-overiding the width 100% declaration to match size of % based container */
.has-docked-nav .navbar > .container {
width: 80%; }

/* Popover */
.popover.open {
display: block;
}
.popover {
display: none;
position: absolute;
top: 0;
left: 0;
background: #fff;
border: 1px solid #eee;
border-radius: 4px;
top: 92%;
left: -50%;
-webkit-filter: drop-shadow(0 0 6px rgba(0,0,0,.1));
-moz-filter: drop-shadow(0 0 6px rgba(0,0,0,.1));
filter: drop-shadow(0 0 6px rgba(0,0,0,.1)); }
.popover-item:first-child .popover-link:after,
.popover-item:first-child .popover-link:before {
bottom: 100%;
left: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none; }
.popover-item:first-child .popover-link:after {
border-color: rgba(255, 255, 255, 0);
border-bottom-color: #fff;
border-width: 10px;
margin-left: -10px; }
.popover-item:first-child .popover-link:before {
border-color: rgba(238, 238, 238, 0);
border-bottom-color: #eee;
border-width: 11px;
margin-left: -11px; }
.popover-list {
padding: 0;
margin: 0;
list-style: none; }
.popover-item {
padding: 0;
margin: 0; }
.popover-link {
position: relative;
color: #222;
display: block;
padding: 8px 20px;
border-bottom: 1px solid #eee;
text-decoration: none;
text-transform: uppercase;
font-size: 1.0rem;
font-weight: 600;
text-align: center;
letter-spacing: .1rem; }
.popover-item:first-child .popover-link {
border-radius: 4px 4px 0 0; }
.popover-item:last-child .popover-link {
border-radius: 0 0 4px 4px;
border-bottom-width: 0; }
.popover-link:hover {
color: #fff;
background: #33C3F0; }
.popover-link:hover,
.popover-item:first-child .popover-link:hover:after {
border-bottom-color: #33C3F0; }
}
1 change: 1 addition & 0 deletions app/naprr/public/css/dc.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit cd556bf

Please sign in to comment.