diff options
author | Matthew Somerville <matthew@mysociety.org> | 2012-05-16 14:30:30 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2012-05-16 14:30:30 +0100 |
commit | d9f3bd47a94116871893f0417e7c836400bb04eb (patch) | |
tree | 1c140a6cb9ea3fd60dbf1532d2cb0bcfdaa703ad /bin | |
parent | 1ba0a33c9fa19f2fa46f16678785d1c90ed33eb0 (diff) | |
parent | 194173589eed229567646cedfc0e32621d18f1e7 (diff) |
Merge branch 'master' into bromley
Conflicts:
bin/send-reports
conf/crontab.ugly
conf/general.yml-example
db/schema.sql
perllib/FixMyStreet/App/Controller/Admin.pm
perllib/FixMyStreet/App/Controller/Report/New.pm
perllib/FixMyStreet/DB/Result/Comment.pm
perllib/FixMyStreet/DB/Result/Open311conf.pm
perllib/FixMyStreet/DB/Result/Problem.pm
perllib/FixMyStreet/DB/Result/User.pm
templates/web/default/js/validation_strings.html
templates/web/fixmystreet/auth/sign_out.html
templates/web/fixmystreet/report/new/councils_text_all.html
web/cobrands/fixmystreet/_base.scss
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/kasabi | 18 | ||||
-rwxr-xr-x | bin/problem-creation-graph | 2 | ||||
-rwxr-xr-x | bin/problems-filed-graph | 2 |
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 |