[models] Added automatic removal of old nodes #46#78
[models] Added automatic removal of old nodes #46#78nemesifier merged 1 commit intoopenwisp:masterfrom
Conversation
nemesifier
left a comment
There was a problem hiding this comment.
great work Aarnav!
Please just add the possibility to turn off (setting to False) and set this by default (we don't want to users upgrading to the latest version to find out about this new feature because they lost data).
Also add mention of this new setting in the README.
As usualy, new features must always be mentioned somewhere in the documentation because otherwise is as if they don't exist, keep this always in mind.
| +--------------+--------------------------------+ | ||
| | **type**: | ``int`` | | ||
| +--------------+--------------------------------+ | ||
| | **default**: | ``False`` | |
|
|
||
| If a node has not been modified since the days specified and if it's link is down, | ||
| it will be deleted by the``update_topology`` management command. | ||
| Replace False with an integer to enable the feature. |
nemesifier
left a comment
There was a problem hiding this comment.
Hey @R9295,
only now that I wanted to merge this I realized this can't really work in the real world.
In short, we can implement this in a much simpler way:
we can query for nodes who have an old date (like you are doing now) but which don't have any link (right now we check if they have both link with status 'down'); we can consider these nodes as expired because they had links which were down and have been deleted by Link.delete_expired_links().
So a node is expired when not only has very old modified date (higher than the expiration days set), but also when it has no links to it.
The query to obtain such nodes would be:
Node.objects.filter(modified__lt=expiration_date,
source_link_set__isnull=True,
target_link_set__isnull=True)Once you get these nodes you can simply delete them if the feature is enabled.
This reasoning implies that this feature depends on NETJSONGRAPH_LINK_EXPIRATION being active.
Could you implement this changes?
I'd really like to add this feature. Let me know.
Federico
|
@nemesisdesign Yep, I'll implement it |
Implements and closes openwisp#46
nemesifier
left a comment
There was a problem hiding this comment.
Excellent, the implementation also looks a lot cleaner.
I will test it on a real network and let you know if it works well :-)
Implements and closes #46