diff --git a/app.json b/app.json index 1540dab3..fa2e0de1 100644 --- a/app.json +++ b/app.json @@ -1,8 +1,13 @@ { + "scripts": { + "dokku": { + "postdeploy": "curl https://api.pmg.org.za/v2/bill-tracker/update/" + } + }, "cron": [ { - "command": "curl api.pmg.org.za/v2/bill-tracker/update/ > /var/log/cron-bill-tracker", - "schedule": "0 1 * * *" + "command": "curl https://api.pmg.org.za/v2/bill-tracker/update/", + "schedule": "@daily" } ] } \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 997fa597..1081004e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -23,7 +23,7 @@ services: volumes: - .:/app environment: - - FLASK_DEBUG_CACHE=true + - FLASK_DEBUG_CACHE=false - REDIS_URL=redis://redis:6379/0 - SQLALCHEMY_DATABASE_URI=postgresql://pmg:pmg@postgres/pmg?client_encoding=utf8 - ES_SERVER=http://elastic:9200 diff --git a/pmg/api/v2.py b/pmg/api/v2.py index eb95c6ea..49e7d806 100644 --- a/pmg/api/v2.py +++ b/pmg/api/v2.py @@ -4,6 +4,8 @@ from sqlalchemy.orm import defer, noload from sqlalchemy.sql.expression import nullslast from pmg.bill_tracker import produce_bill_tracker_json +from pmg import app +import requests from pmg import cache, cache_key, should_skip_cache from pmg.models import ( @@ -265,3 +267,10 @@ def bill_tracker(): def bill_tracker_update(): produce_bill_tracker_json() return "/v2/bill-tracker JSON updated" + + +@api.route("/elasticsearch-health") +def elasticsearch_health(): + r = requests.get("%s/_cluster/health?pretty=true" % app.config["ES_SERVER"]) + r.raise_for_status() + return r.json() diff --git a/pmg/models/resources.py b/pmg/models/resources.py index a4f3df82..c2d5a0bc 100644 --- a/pmg/models/resources.py +++ b/pmg/models/resources.py @@ -187,7 +187,10 @@ def latest_version_for_indexing(self): if not version: # don't return None return [] - return base64.encodestring(version.file.get_bytes()) + try: + return base64.encodestring(version.file.get_bytes()) + except AttributeError as e: + return [] def to_dict(self, include_related=False): tmp = serializers.model_to_dict(self, include_related=include_related) diff --git a/pmg/templates/bills/detail.html b/pmg/templates/bills/detail.html index 40b2135d..1c3c973f 100644 --- a/pmg/templates/bills/detail.html +++ b/pmg/templates/bills/detail.html @@ -152,13 +152,13 @@
A preview of this file is not available. Please download it instead.
diff --git a/pmg/templates/committee_layout.html b/pmg/templates/committee_layout.html index 0c5cbe94..3db217e3 100644 --- a/pmg/templates/committee_layout.html +++ b/pmg/templates/committee_layout.html @@ -1,16 +1,25 @@ {% extends "base.html" %} -{% block title %}{{ committee.name }} | PMG{% endblock %} +{% block title %} + {% if committee %} + {{ committee.name }} | + {% endif %} + PMG +{% endblock %} {% block breadcrumb %}