aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/kasabi18
-rwxr-xr-xbin/problem-creation-graph2
-rwxr-xr-xbin/problems-filed-graph2
3 files changed, 13 insertions, 9 deletions
diff --git a/bin/kasabi b/bin/kasabi
index 986032084..5b99ba4ff 100755
--- a/bin/kasabi
+++ b/bin/kasabi
@@ -27,9 +27,16 @@ cursor = db.cursor(cursor_factory=psycopg2.extras.RealDictCursor)
report_cursor = db.cursor(cursor_factory=psycopg2.extras.RealDictCursor)
def main():
- # Fetch reports that have changed recently
- #response, data = dataset.select('select (max(?lastupdate) as ?max) where { ?report <http://data.kasabi.com/dataset/fixmystreet/def/lastUpdate> ?lastupdate }')
- #max_lastUpdate = data[1][0]['max']
+
+ # Check the status of our dataset
+ response, status = dataset.status()
+ if response.status not in range(200, 300) or status['storageMode'] == 'read-only':
+ # We can't import anything, so let's not bother
+ sys.exit()
+
+ # Fetch reports that have changed since last update in dataset
+ response, data = dataset.select('select (max(?lastupdate) as ?max) where { ?report <http://data.kasabi.com/dataset/fixmystreet/def/lastUpdate> ?lastupdate }')
+ max_lastUpdate = data[1][0]['max']
query = """
SELECT id, latitude, longitude, used_map, council,
category, title, detail, (photo IS NOT NULL) as photo,
@@ -40,10 +47,7 @@ def main():
if len(sys.argv) > 1 and sys.argv[1].isdigit():
cursor.execute("%s AND id=%%s" % query, (sys.argv[1],))
else:
- last_hour = datetime.datetime.now().replace(minute=0, second=0, microsecond=0) - datetime.timedelta(hours=1)
- cursor.execute("%s AND date_trunc('hour', lastupdate) = %%s" % query, (last_hour,))
-# AND lastupdate > %s
-# """, (max_lastUpdate,))
+ cursor.execute("%s AND lastupdate > %%s ORDER BY lastupdate" % query, (str(max_lastUpdate),))
for report in cursor:
changeset = FixMyStreetChangeSet(dataset)
diff --git a/bin/problem-creation-graph b/bin/problem-creation-graph
index 4bba1cdb8..6692ae724 100755
--- a/bin/problem-creation-graph
+++ b/bin/problem-creation-graph
@@ -104,6 +104,6 @@ END
#echo "gpscript $GPSCRIPT"
export GDFONTPATH=/usr/share/fonts/truetype/ttf-bitstream-vera
-gnuplot < $GPSCRIPT > fixmystreet/web/bci-live-creation$EXTENSION
+gnuplot < $GPSCRIPT > fixmystreet/web/bci-live-creation$EXTENSION 2>/dev/null
diff --git a/bin/problems-filed-graph b/bin/problems-filed-graph
index dbac35639..8addacd62 100755
--- a/bin/problems-filed-graph
+++ b/bin/problems-filed-graph
@@ -57,5 +57,5 @@ END
#echo "gpscript $GPSCRIPT"
export GDFONTPATH=/usr/share/fonts/truetype/ttf-bitstream-vera
-gnuplot < $GPSCRIPT > fixmystreet/web/bci-live-line$EXTENSION
+gnuplot < $GPSCRIPT > fixmystreet/web/bci-live-line$EXTENSION 2>/dev/null