[models] Added link status up/down time #43#73
Conversation
There was a problem hiding this comment.
Good progress @R9295.
We need to show this information in the API so it appears in the visualizer.
We don't need to show it in the admin so you can safely remove the admin code.
Take a look at how some fields are added into the "properties" section of the NetJSON nodes, which are shown in the visualizer: https://github.com/netjson/django-netjsongraph/blob/master/django_netjsongraph/base/node.py#L87-L100
You need to do something similar with this new field.
PS: me and @rohithasrk forgot to create a migration in the previous release, delete the migration you created, rebase on current master and regenerate the migration
| blank=True, | ||
| load_kwargs={'object_pairs_hook': OrderedDict}, | ||
| dump_kwargs={'indent': 4}) | ||
| last_status_change = models.DateTimeField(auto_now=True) |
There was a problem hiding this comment.
Renamed to status_changed for consistency with the created and modified fields
| class AbstractLinkAdmin(BaseAdmin): | ||
| raw_id_fields = ['source', 'target'] | ||
| list_display = ['__str__', 'topology', 'status', 'cost', 'cost_text'] | ||
| list_display = ['__str__', 'topology', 'status', 'cost', 'cost_text', 'uptime_or_downtime'] |
There was a problem hiding this comment.
let's not add this information in the admin list, we need to show this in the visualizer
| def send_status_changed_signal(self): | ||
| link_status_changed.send(sender=self.__class__, link=self) | ||
|
|
||
| def last_status_change_diff(self): |
There was a problem hiding this comment.
I came to the conclusion that we can simplify the implementation and remove this addition because calculating this for each node in a large graph would slow down the generation of the NetworkGraph even further to little advantage. By returning the status_changed field in the API frontend javascript implementations can calculate this value on the fly - and having the raw value is good enough for now.
f2ec641 to
4ec15ec
Compare
Implements and closes openwisp#43
Implements and closes #43