Skip to content

Commit

Permalink
han: merged staging into current branch
Browse files Browse the repository at this point in the history
  • Loading branch information
leehanchung committed Apr 10, 2020
2 parents d593ab1 + 4ac66a6 commit 5efce75
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 30 deletions.
35 changes: 35 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Description

What Changed ? e.g. Github Issues Title or Trello Card Title

## Type of change

Please delete options that are not relevant.

- [ ] :art: CSS Styling fix
- [ ] :ambulance: Bug fix (non-breaking change which fixes an issue)
- [ ] :recycle: :wastebasket: Re-factor, cleanup, un-comment, docstring
- [ ] :sparkles: New feature (non-breaking change which adds functionality)
- [ ] :boom: Breaking change (fix or feature that would cause existing functionality to not work as expected)

## Change Status

- [ ] :checkered_flag: Complete, tested, ready to review and merge
- [ ] :traffic_light: Complete, but not tested (may need new tests)
- [ ] :construction: WIP work-in-progress, PR is for discussion/feedback

# How Has This Been Tested?

- [ ] Manually Functionality Testing
- [ ] Unit Test

# Checklist

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] There are no merge conflicts
4 changes: 0 additions & 4 deletions components/column_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
import pandas as pd


# DEPRECATED?
# TODO: Remove logic from here and put it to AWS Lambda

# worked when i moved this into the try/except in the states_confirmed_stats function
try:
URL = config.NCOV19_API + config.COUNTY
response = requests.get(URL).json()
Expand Down
1 change: 0 additions & 1 deletion components/column_stats_mobile.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import pandas as pd


# TODO: Remove logic from here and put it to AWS Lambda
try:
URL = config.NCOV19_API + config.COUNTY
response = requests.get(URL).json()
Expand Down
2 changes: 1 addition & 1 deletion components/new_infection_trajectory_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@



# @cache.memoize(timeout=3600)
@cache.memoize(timeout=3600)
def new_infection_trajectory_chart(state="US") -> go.Figure:
"""Line chart data for the selected state.
Expand Down
41 changes: 23 additions & 18 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from pages import about_body
from pages import mobile, mobile_navbar, mobile_footer
from pages import mobile_about_body

from utils import config

# Set default layout so Flask can start
app.layout = build_desktop_layout
Expand All @@ -37,8 +37,8 @@ def before_request_func():

if is_mobile:
app.layout = build_mobile_layout
flask.session['mobile'] = True
flask.session['zoom'] = 1.9#2.0
flask.session["mobile"] = True
flask.session["zoom"] = 1.9 # 2.0
else: # Desktop request
app.layout = build_desktop_layout
flask.session['mobile'] = False
Expand All @@ -62,15 +62,15 @@ def sitemap():
for rule in server.url_map.iter_rules():
if not str(rule).startswith("/admin") and not str(rule).startswith("/user"):
if "GET" in rule.methods and len(rule.arguments) == 0:
url = {
"loc": f"{host_base}{str(rule)}"
}
url = {"loc": f"{host_base}{str(rule)}"}
static_urls.append(url)

static_urls.append({"loc": f"{host_base}/about"})
static_urls.append({"loc": f"{host_base}/resources"})

xml_sitemap = render_template("sitemap.xml", static_urls=static_urls, host_base=host_base) #, dynamic_urls=dynamic_urls,
xml_sitemap = render_template(
"sitemap.xml", static_urls=static_urls, host_base=host_base
) # , dynamic_urls=dynamic_urls,
response = make_response(xml_sitemap)
response.headers["Content-Type"] = "application/xml"

Expand All @@ -83,12 +83,16 @@ def static_from_root():
"""
response = send_from_directory(server.static_folder, request.path[1:])
return response


@app.callback([Output("navbar-content", "children"),
Output("page-content", "children"),
Output("footer-content", "children")],
[Input("url", "pathname")])

@app.callback(
[
Output("navbar-content", "children"),
Output("page-content", "children"),
Output("footer-content", "children"),
],
[Input("url", "pathname")],
)
def display_page(pathname):
is_mobile = flask.session['mobile']

Expand All @@ -106,11 +110,12 @@ def display_page(pathname):
error_page = [
html.Div(
html.Img(
src='assets/images/404_image.png',
style={"margin": "0 auto",
"width": "100%",
"display": "flex",
"padding": "5vh 2vw",
src="assets/images/404_image.png",
style={
"margin": "0 auto",
"width": "100%",
"display": "flex",
"padding": "5vh 2vw",
},
),
),
Expand All @@ -122,4 +127,4 @@ def display_page(pathname):


if __name__ == "__main__":
app.run_server(debug=True)
app.run_server(debug=config.DEBUG)
9 changes: 8 additions & 1 deletion static/robots.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
Sitemap: https://ncov19.us/sitemap.xml

User-agent: Googlebot
Crawl-delay: 10
Disallow:

User-agent: Mediapartners-Google
Crawl-delay: 10
Disallow:

User-agent: bingbot
Crawl-delay: 5
Crawl-delay: 10
Disallow:

User-agent: Twitterbot
Crawl-delay: 10
Disallow:

User-agent: ia_archiver
Crawl-delay: 10
Disallow:

User-agent: Bytespider
Expand Down
10 changes: 9 additions & 1 deletion utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
from utils.config import *
from utils.settings import *
import os

config = ProductionConfig()
STAGING = os.environ["STAGING"]

if STAGING == "True":
config = StagingConfig()
else:
config = ProductionConfig()

# print(f"[DEBUG] Config being used is: {config.__class__.__name__}")
8 changes: 4 additions & 4 deletions utils/config.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from decouple import config


class Config(object):
class StagingConfig(object):
"""Base config, uses staging API"""

DEBUG = False
TESTING = False
DEBUG = True
TESTING = True

# Secret Key
SECRET_KEY = config("SECRET_KEY")
Expand All @@ -31,7 +31,7 @@ class Config(object):
DRIVE_THRU_URL = config("DRIVE_THRU_STAGING_URL")


class ProductionConfig(Config):
class ProductionConfig(StagingConfig):
"""Uses production database server."""

DEBUG = False
Expand Down

0 comments on commit 5efce75

Please sign in to comment.