Skip to content

Commit

Permalink
upload firebase files
Browse files Browse the repository at this point in the history
  • Loading branch information
lloydoad committed Aug 24, 2019
1 parent e8daa30 commit 09c8f0d
Show file tree
Hide file tree
Showing 13 changed files with 2,227 additions and 100 deletions.
5 changes: 5 additions & 0 deletions .firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": "feast-server"
}
}
154 changes: 54 additions & 100 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,111 +1,65 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
# Logs
logs
*.log
local_settings.py
db.sqlite3
npm-debug.log*
yarn-debug.log*
yarn-error.log*
firebase-debug.log*

# Flask stuff:
instance/
.webassets-cache
# Firebase cache
.firebase/

# Scrapy stuff:
.scrapy
# Firebase config

# Sphinx documentation
docs/_build/
# Uncomment this if you'd like others to create their own Firebase project.
# For a team working on the same Firebase project(s), it is recommended to leave
# it commented so all members can deploy to the same project(s) in .firebaserc.
# .firebaserc

# PyBuilder
target/
# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Jupyter Notebook
.ipynb_checkpoints
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# pyenv
.python-version
# Coverage directory used by tools like istanbul
coverage

# celery beat schedule file
celerybeat-schedule
# nyc test coverage
.nyc_output

# SageMath parsed files
*.sage.py
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Environments
# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/

# private keys
credentials.json
business.json
ignore.txt
.idea/
.DS_Store
14 changes: 14 additions & 0 deletions firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [{
"source": "**",
"function": "app"
}]
}
}
1 change: 1 addition & 0 deletions functions/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
Binary file added functions/files/.DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions functions/files/AdjacencyList.json

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions functions/files/CutOffs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"lowerCutOff": 41,
"upperCutOff": 197
}
67 changes: 67 additions & 0 deletions functions/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@

const classifier = require("./source/classifier");
const cutoffs = require("./files/CutOffs.json");

const functions = require('firebase-functions');
const express = require('express');

const app = express();

const PREFERENCE_QUERY_PARAMETER = 'classifiers';

app.get('/timestamp', (req, res) => {
res.send(`${Date.now()}`);
});

app.get('/setup', (req, res) => {
let parameters = [];

if(req.query[PREFERENCE_QUERY_PARAMETER] != null) {
parameters = req.query[PREFERENCE_QUERY_PARAMETER];
console.log("Setup classifiers requested with " + parameters.length + " params");
} else {
console.log("Setup classifiers requested");
}

let picks = classifier.getInitialClassifiers(cutoffs, parameters);

res.status(200).json(picks);
});

app.get('/addon', (req, res) => {
let parameters = [];

if(req.query[PREFERENCE_QUERY_PARAMETER] == null) {
console.log("Bad request query");
res.status(404).json('No preference specified');
return
} else {
parameters = req.query[PREFERENCE_QUERY_PARAMETER];
}

if(parameters instanceof Array && parameters.length == 0) {
res.status(404).json('Bad request query');
return;
}

if(parameters instanceof Array)
parameters = parameters[0];

let errors = {};
console.log(`Add-on to ${parameters} requested`);
const results = classifier.getSubsequentClassifiers(cutoffs, parameters, errors);

if(results == null) {
res.status(404).json(errors.message);
return;
} else {
res.status(200).json(results);
return;
}
})

app.get('/restaurants', (req, res) => {
res.status(400).json('Route has been deprecated. Please use other map APIs for this feature');
})

exports.app = functions.https.onRequest(app);
Loading

0 comments on commit 09c8f0d

Please sign in to comment.