1
0
Fork 0

Add command update_station_last_seen

merge-requests/638/head
Fabian P. Schmidt 2018-12-10 02:28:59 +01:00
parent 4f3c419cdf
commit 068b7cf9d7
2 changed files with 30 additions and 0 deletions

View File

@ -94,6 +94,15 @@ Manually add the new required files to the list of "assets" in packages.json, th
The assets are stored in the repository, thus don't forget to create a commit after you add/update/remove dependencies.
Simulating station heartbeats
-----------------------------
Only stations which have been seen by the server in the last hour (by default, can be customized by `STATION_HEARTBEAT_TIME`)
are taken into consideration when scheduling observations. In order to simulate an heartbeat of the stations 7, 23 and 42,
the following command can be used
$ sudo docker-compose run web python manage.py update_station_last_seen 7 23 42
Coding Style
------------

View File

@ -0,0 +1,21 @@
from django.core.management.base import LabelCommand
from django.utils.timezone import now
from network.base.models import Station
class Command(LabelCommand):
args = '<Station IDs>'
help = 'Updates Last_Seen Timestamp for given Stations'
def handle_label(self, label, **options):
try:
gs = Station.objects.get(id=label)
except Station.DoesNotExist:
self.stderr.write('Station with ID {} does not exist'.format(label))
return
timestamp = now()
gs.last_seen = timestamp
gs.save()
self.stdout.write('Updated Last_Seen for Station {} to {}'.format(label, timestamp))