Add a script to purge old GCUM reports

This commit is contained in:
Lucas Verney 2018-06-28 15:58:36 +02:00
parent 4493dc35fe
commit d35e759200
4 changed files with 31 additions and 3 deletions

View File

@ -63,11 +63,18 @@ adapt its behavior:
`sqlite:///reports.db` which means a SQLite database named `reports.db` in
the current working directory).
### Serving
### Serving in production
You can use the `wsgi.py` script at the root of the git repository to serve
the server side part.
### Useful scripts
The `scripts` folder contain some useful scripts:
* `purge_old_gcum.py` deletes `gcum`-type report older than one hour. You
should set a crontask to call it regularly.
## Contributing

21
scripts/purge_old_gcum.py Normal file
View File

@ -0,0 +1,21 @@
#!/usr/bin/env python
# coding: utf-8
import os
import sys
SCRIPT_DIRECTORY = os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.abspath(os.path.join(SCRIPT_DIRECTORY, '..')))
import arrow
from server.models import db, Report
if __name__ == "__main__":
db.connect()
one_hour_ago = arrow.utcnow().shift(hours=-1).datetime
nb = Report.delete().where(
(Report.type == 'gcum') &
(Report.datetime < one_hour_ago)
).execute()
print("%d GCUM reports purged." % nb)
if not db.is_closed():
db.close()

View File

@ -2,7 +2,7 @@
export default {
about: {
availableReportsTitle: 'The available reports so far are:',
gcumDescription: 'A car poorly parked on a bike lane.',
gcumDescription: 'A car poorly parked on a bike lane. Such reports are automatically deleted after one hour, as they are by nature temporary.',
interruptDescription: 'An interruption of the bike lane (works, unexpected end of the bike lane, etc.).',
license: 'It is released under an <a href="https://opensource.org/licenses/MIT">MIT license</a>. The map background is using tiles from <a href="https://www.opencyclemap.org/docs/">OpenCycleMap</a>, thanks to <a href="https://www.openstreetmap.org/copyright">OpenStreetMap contributors</a> and <a href="http://leafletjs.com/">Leaflet</a>.',
potholeDescription: 'A pothole in the ground.',

View File

@ -2,7 +2,7 @@
export default {
about: {
availableReportsTitle: "Les signalements disponibles pour l'instant sont :",
gcumDescription: 'Une voiture (mal) garée sur la piste cyclable.',
gcumDescription: "Une voiture (mal) garée sur la piste cyclable. Ces signalements sont automatiquement supprimés au bout d'une heure car ils sont par essence temporaires.",
interruptDescription: "Une interruption d'itinéraire cyclable (travaux, arrêt inattendu d'une piste cyclable, etc)",
license: "Le code source est sous <a href='https://opensource.org/licenses/MIT'>licence MIT license</a>. Les tuiles de fond de carte proviennent de chez <a href='https://www.opencyclemap.org/docs/'>OpenCycleMap</a>, grace aux <a href='https://www.openstreetmap.org/copyright'>contributeurs OpenStreetMap</a> et à <a href='http://leafletjs.com/'>Leaflet</a>.",
potholeDescription: 'Un nid de poule dans la route.',