<commit_before># Open Energy Dashboard #
[![Build Status](https://travis-ci.org/OpenEnergyDashboard/OED.svg?branch=master)](https://travis-ci.org/OpenEnergyDashboard/OED)

The Open Energy Dashboard is a user-friendly way to display energy information from smart energy meters, designed and built by faculty and students at Beloit College. It is designed for institutions of higher education, and is optimized for non-technical users with a simple interface that provides access to your institution's energy data through the powerful Chart.js data graphing system. To learn more, see [our website](https://openenergydashboard.github.io/).

The Open Energy Dashboard is available under the Mozilla Public Licence, and contributions, in the form of bug reports, feature requests, and code contributions, are welcome.

### Built With ###
Chart.js - Javascript library used to generate data charts ([chartjs.org](http://www.chartjs.org))

PostgreSQL - Database management system ([postgresql.org](https://www.postgresql.org))

Node.js - Javascript runtime environment ([nodejs.org](https://nodejs.org/en/))

### Developer Installation ###

You can either use Docker Compose to install Node and PostgreSQL in containers, or install Node and PostgreSQL on your system.

#### Without Docker ####

1. Install Node, npm, and git.
1. Clone this repository.
1. Run ```npm install``` in the project root directory.
1. Install PostgreSQL, start the PostgreSQL server, and connect to it via psql.
1. In psql, run ```CREATE DATABASE oed;``` to create the database.
1. Still in psql, run ```CREATE DATABASE oed_testing;``` to create a database for automated tests.
1. Create a .env file in the root directory of the project with the following, replacing (?) with the desired information: <br>
```
SERVER_PORT=?              // The port that the server should run on. 3000 is a good default choice
DB_USER=?                  // The user that should be used to connect to postgres
DB_DATABASE=?              // The database you just created, so likely oed
DB_TEST_DATABASE=?         // The test database you just created, so likely oed_testing
DB_PASSWORD=?              // The password for your postgres user
DB_HOST=?                  // The host for your postgres db, likely localhost
DB_PORT=?                  // The port for your postgres db, likely 5432
TOKEN_SECRET=?             // Token for authentication. Generate something secure and random
LOG_FILE=?                 // Path to the log file, defaults to ./log.txt
```
8. Run ```npm run createdb``` to create the database schema.
1. Run `npm run addMamacMeters` to load mamac meters from an `.csv` file.
1. Run `npm run updateMamacMeters` to fetch new data for mamac meters in the database.
1. Run `npm run createUser` and follow the directions to create a new admin user.
1. Run ```npm run build``` to create the Webpack bundle for production, otherwise run ```npm run dev``` for development.
1. Run ```npm start```

#### With Docker ####

1. Install [Docker](https://docs.docker.com/engine/installation/) and [docker-compose](https://docs.docker.com/compose/install/).
1. Clone this repository.
1. Set up Node environment and the database by running ```docker-compose run --rm web src/scripts/init.sh <csv file>``` in the main directory. 
1. Start the app in development mode with ```docker-compose run --rm --service-ports web src/scripts/devstart.sh```.


To clarify: ```docker-compose run --rm web``` means run the following command, in the ```web``` container (the one containing the OED NodeJS app). 
With the init script, you can either provide a CSV file with the IPs of some Mamac meters, in which case the database will be populated, or enter NONE, which will skip populating it.

For production, run the app with ```docker-compose up -d```. This starts the app as a daemon. Stop the app with ```docker-compose stop```. 

You can get rid of the containers with ```docker-compose down```. Until you do that, you can skip step 3 on subsequent runs.<commit_msg>Add OED_ to env variables in README, fix small README typos<commit_after># Open Energy Dashboard #
[![Build Status](https://travis-ci.org/OpenEnergyDashboard/OED.svg?branch=master)](https://travis-ci.org/OpenEnergyDashboard/OED)

Open Energy Dashboard is a user-friendly way to display energy information from smart energy meters, designed and built by faculty and students at Beloit College. It is designed for institutions of higher education, and is optimized for non-technical users with a simple interface that provides access to your institution's energy data through the powerful Chart.js data graphing system. To learn more, see [our website](https://openenergydashboard.github.io/).

Open Energy Dashboard is available under the Mozilla Public Licence v2, and contributions, in the form of bug reports, feature requests, and code contributions, are welcome.

### Built With ###
Chart.js - JavaScript library used to generate data charts ([chartjs.org](http://www.chartjs.org))

PostgreSQL - Database management system ([postgresql.org](https://www.postgresql.org))

Node.js - JavaScript runtime environment ([nodejs.org](https://nodejs.org/en/))

### Developer Installation ###

You can either use Docker Compose to install Node and PostgreSQL in containers, or install Node and PostgreSQL on your system.

#### Without Docker ####

1. Install Node, npm, and git.
1. Clone this repository.
1. Run ```npm install``` in the project root directory.
1. Install PostgreSQL, start the PostgreSQL server, and connect to it via psql.
1. In psql, run ```CREATE DATABASE oed;``` to create the database.
1. Still in psql, run ```CREATE DATABASE oed_testing;``` to create a database for automated tests.
1. Create a .env file in the root directory of the project with the following, replacing (?) with the desired information: <br>
```
OED_SERVER_PORT=?              // The port that the server should run on. 3000 is a good default choice
OED_DB_USER=?                  // The user that should be used to connect to postgres
OED_DB_DATABASE=?              // The database you just created, so likely oed
OED_DB_TEST_DATABASE=?         // The test database you just created, so likely oed_testing
OED_DB_PASSWORD=?              // The password for your postgres user
OED_DB_HOST=?                  // The host for your postgres db, likely localhost
OED_DB_PORT=?                  // The port for your postgres db, likely 5432
OED_TOKEN_SECRET=?             // Token for authentication. Generate something secure and random
OED_LOG_FILE=?                 // Path to the log file, defaults to ./log.txt
```
8. Run ```npm run createdb``` to create the database schema.
1. Run `npm run addMamacMeters` to load mamac meters from an `.csv` file.
1. Run `npm run updateMamacMeters` to fetch new data for mamac meters in the database.
1. Run `npm run createUser` and follow the directions to create a new admin user.
1. Run ```npm run build``` to create the Webpack bundle for production, otherwise run ```npm run dev``` for development.
1. Run ```npm start```

#### With Docker ####

1. Install [Docker](https://docs.docker.com/engine/installation/) and [docker-compose](https://docs.docker.com/compose/install/).
1. Clone this repository.
1. Set up Node environment and the database by running ```docker-compose run --rm web src/scripts/init.sh <csv file>``` in the main directory. 
1. Start the app in development mode with ```docker-compose run --rm --service-ports web src/scripts/devstart.sh```.


To clarify: ```docker-compose run --rm web``` means run the following command, in the ```web``` container (the one containing the OED NodeJS app). 
With the init script, you can either provide a CSV file with the IPs of some Mamac meters, in which case the database will be populated, or enter NONE, which will skip populating it.

For production, run the app with ```docker-compose up -d```. This starts the app as a daemon. Stop the app with ```docker-compose stop```. 

You can get rid of the containers with ```docker-compose down```. Until you do that, you can skip step 3 on subsequent runs.
{'fraction_non_alphanumeric': 0.09613723312353449, 'fraction_numerical': 0.006540787362705171, 'mean_word_length': 3.755868544600939, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 14, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7259931', 'n_tokens_mistral': 2275, 'n_tokens_neox': 2182, 'n_words': 1072}