Skip to content

Conversation

DragnEmperor
Copy link
Member

@DragnEmperor DragnEmperor commented Jun 12, 2025

Checklist

  • I have read the OpenWISP Contributing Guidelines.
  • I have manually tested the changes proposed in this pull request.
  • I have written new test cases for new code and/or updated existing tests for changes to existing code.
  • I have updated the documentation.

Reference to Existing Issue

Closes #1034.

Description of Changes

Fuzzy locations task is added to allow creation of such locations when WhoIs is created for the same device. Also the task should attach the device to an existing location if already WhoIs is available for that device.

Scenarios for estimated locations:

  • When a device has last_ip having no WHOIS record, then the WHOIS record should be created and a new location should be created for the device. The location must be updated with latest coordinates when last_ip of device is updated.
  • When a device (A) has last_ip, which has WHOIS record, then the location of existing device (B) of same ip should be attached to device A, if:
    • A either has no location or A's location is estimated. If either fails, then location should be created/updated using coordinates from WHOIS record
    • there is only one existing device with location. In case there are multiple devices with same last_ip and they have locations then a notification must be sent to user notifying them for the same and asking them to resolve this manually.
      In case A has a location which is estimated then it should be deleted before attaching an already existing location.
  • If two devices A and B have same last_ip which implies they are attached to same location then if either device updates their last_ip (suppose A does) then A should have a new location created with the coordinates for the latest last_ip.

@DragnEmperor DragnEmperor changed the title Issues/1034 fuzzy location creation [feature] Fuzzy location creation Jun 12, 2025
@DragnEmperor DragnEmperor self-assigned this Jun 13, 2025
@DragnEmperor DragnEmperor added enhancement gsoc Part of a Google Summer of Code project labels Jun 13, 2025
@DragnEmperor DragnEmperor changed the base branch from gsoc25-whois to issues/1032-1033-whois-setup June 25, 2025 18:58
@DragnEmperor DragnEmperor force-pushed the issues/1034-fuzzy-location-creation branch 2 times, most recently from 6643b32 to 73c3b0a Compare June 30, 2025 08:16
Base automatically changed from issues/1032-1033-whois-setup to gsoc25-whois June 30, 2025 18:26
@DragnEmperor DragnEmperor force-pushed the issues/1034-fuzzy-location-creation branch from 73c3b0a to 44fa3e9 Compare July 1, 2025 13:42
"""

# Check cheap conditions first before hitting the database
if not self.is_valid_public_ip_address(new_ip):
return False
return False, False
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that we should not club this logic here. Although you added the comment, but still name of the function doesn't explain why we are returning two booleans. Can't we create one more function to check if WHOIS info exist?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These checks are dependent on each other. We need to trigger the task when WHOIS already exists for an IP. I will still look into this to find another approach

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, we should not change the return type for this function.

transaction.on_commit(
lambda: fetch_whois_details.delay(
device_pk=self.device.pk,
initial_ip_address=self.device._initial_last_ip,
new_ip_address=self.device.last_ip,
)
)
elif whois_info_exists and self.is_whois_enabled:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WHOIS information should exist only when WHOIS is enabled. Do you mean that if WHOIS is disabled after checksum occurs and WHOIS info is added in DB? What are the consequences if we show fuzzy location for that last_ip only whether WHOIS is enabled or not?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think we are deleting existing WHOIS information if WHOIS is disabled for an organization as for some org it may be enabled, we are just not adding that information for that org's device admin and api endpoints.

This check above is to tackle the early fallback when the above condition for fetch_whois_details fail as WHOIS already exists. The task manage_fuzzy_locations in that case will attach the location of an already existing device having same ip to current device. I have defined this behavior in the task's docstring

Also IMO there should not be a problem if fuzzy locations exist irrespective of WHOIS is enabled or not as it just informs the approximate nature of the location. But still if we need to make any changes to fuzzy locations based on WHOIS enabled or not please let me know.

@DragnEmperor DragnEmperor marked this pull request as ready for review July 1, 2025 20:18
@coveralls
Copy link

Coverage Status

coverage: 98.602% (-0.003%) from 98.605%
when pulling 563bb4a on issues/1034-fuzzy-location-creation
into 41e0b55 on gsoc25-whois.

Copy link
Member

@codesankalp codesankalp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we put fuzzy location creation behind a flag? I’m asking because I’m not sure every organization with WHOIS enabled will need it.



@shared_task
def manage_fuzzy_locations(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you simplify this function? It looks like it has too many conditional statements. Also, why aren’t we leveraging the service layer here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will try to make this function more simpler.
Apologies but I am not sure how should i use the service layer here. Also, service file imports this file so we will encounter circular imports if using service here as well

"""

# Check cheap conditions first before hitting the database
if not self.is_valid_public_ip_address(new_ip):
return False
return False, False
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, we should not change the return type for this function.

current_location = device_location.location
if add_existing and (not current_location or current_location.is_approximate):
existing_device_location = (
Device.objects.select_related("devicelocation")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we filter to the current organization’s devices first, rather than checking every device?

@DragnEmperor
Copy link
Member Author

DragnEmperor commented Jul 3, 2025

Should we put fuzzy location creation behind a flag? I’m asking because I’m not sure every organization with WHOIS enabled will need it.

We might have to change some things based on how this feature is expected to work. For instance, do we want this to be a complete separate feature than WHOIS lookup (which will require more changes) or a feature which can be enabled/disabled only if WHOIS is enabled.
P.S. : This is dependent on details of latitude and longitude which we get from WHOIS lookup.

Update: There is also a case which is not handled:

  • when a device's new last_ip already has WHOIS record
  • we try create/update its fuzzy location using the location of existing device having that same last_ip but somehow location of that device does not exists/ deleted by user

In that case we might need to perform WHOIS lookup again which might be a bit costly as per rate limiting of 1000 requests per day. We can change the WHOIS model to store latitude and longitude information as well to ensure we need not perform a lookup again.

Let me know your thoughts!

@DragnEmperor DragnEmperor force-pushed the issues/1034-fuzzy-location-creation branch from 563bb4a to f19ac51 Compare July 3, 2025 19:02
Copy link
Member

@devkapilbansal devkapilbansal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to check the logic for manage_fuzzy_locations once again along with tests. Rest looks good. Have some minor suggestions

Comment on lines 120 to 122
# we are only checking for 2 of the above conditions of `_need_whois_lookup`
# as we need to ensure that the fuzzy locations are managed only if there is
# existing WHOIS record
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment looks confusing to me, we are managing fuzzy locations in fetch_whois_details task also

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the comment for better clarity

Comment on lines 187 to 192
- If attaching existing location and current device has no location then the
existing location is attached to the current device as well.
- If attaching existing location and current device already has location, then
current device's location is deleted and set same as existing device's location.
- If not attaching existing then new location is created if no location exists for
current device, or existing one is updated if it is approximate(fuzzy).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, we can re-write this comment to something more readable like

Suggested change
- If attaching existing location and current device has no location then the
existing location is attached to the current device as well.
- If attaching existing location and current device already has location, then
current device's location is deleted and set same as existing device's location.
- If not attaching existing then new location is created if no location exists for
current device, or existing one is updated if it is approximate(fuzzy).
- If current device already has a location previously, then it is deleted.
- If existing location is not attached, then a new location is created if no location exists for
current device, or existing one is updated if it is approximate(fuzzy).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Based on the suggestions I have modified the doc string

Comment on lines +113 to +133
if not self.is_valid_public_ip_address(new_ip):
return False

if not self.is_whois_enabled:
return False
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think based on our discussion we have decided to do cheap checks first. is_valid_public_ip_address will require an API call and should be done after checking if whois is enabled or not

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Kapil, is_valid_public_ip_address checks if ip address is public or not locally in memory without calling any API hence, it is kept first

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are importing ip_address in first line as well as using some variables with same name. Can we have a clear distinction between the two?
We can write the import line as
from ipaddress import ip_address as something

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I am in favour of renaming the ip_address variable in get_device_whois_info method. I didn't found any other occurence for this.

Comment on lines 13 to 25
Creates/updates fuzzy location for a device based on the latitude and longitude
or attaches an existing location if `add_existing` is True.
Existing location here means a location of another device whose last_ip matches
the given ip_address.
When `add_existing` is True:
- If the current device has no location, attach the existing one; if it does,
update it with the existing one only if it is approximate (fuzzy).
When `add_existing` is False:
- A new location is created if no location exists for current device, or
existing one is updated using coords from WHOIS record if it is approximate(fuzzy).
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏 much better

Comment on lines 27 to 30
migrations.AddField(
model_name="whoisinfo",
name="latitude",
field=models.FloatField(blank=True, help_text="Latitude", null=True),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we any validation checks in the code to ensure that latitude and longitude values are correct?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, I will think of some tests for these as well

mocked_task.assert_not_called()
mocked_task.reset_mock()

with self.subTest(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add one more check if it is not there, task not called via DeviceChecksumView when WHOIS is disabled

@DragnEmperor DragnEmperor force-pushed the issues/1034-fuzzy-location-creation branch 4 times, most recently from 9837a7f to fde52b0 Compare July 15, 2025 19:24
The **Approximate Location** feature is **disabled by default**.

Before enabling it, the :doc:`WHOIS Lookup feature <whois>` must be
enabled and then set
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
enabled and then set
enabled. Then set

Comment on lines 38 to 39
If **a matching location already exists** for another device with the same
IP, the system will **attach that location** to the current device if:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's rewrite this, something like

Suggested change
If **a matching location already exists** for another device with the same
IP, the system will **attach that location** to the current device if:
The system will **attach the already existing matching location** of another device with same ip to the current device if **a matching location if

If **a matching location already exists** for another device with the same
IP, the system will **attach that location** to the current device if:

- Only one device is found with that IP and it has a location.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if more than one device has same ip?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there are more than once devices having the same ip and location then notification will be sent to use as in that case we are not use which device's location to use. Will add this in docs as well

Comment on lines 42 to 43
- The current device **has no location** or if it does then the location
is **approximate**.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- The current device **has no location** or if it does then the location
is **approximate**.
- The current device **has no location** or that location
is **approximate**.

Comment on lines 45 to 47
If there is **no matching location**, a new approximate location is
created or the existing one is updated using coordinates from the WHOIS
record, but only if the existing location is approximate.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If there is **no matching location**, a new approximate location is
created or the existing one is updated using coordinates from the WHOIS
record, but only if the existing location is approximate.
If there is **no matching location** and existing location is approximate (if exists), a new approximate location is
created or the existing one is updated using coordinates from the WHOIS record.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about this as when there is no matching location then it will either create an approximate location else update the existing location only if the existing one is already approximate.
The suggested statement sounds a bit misleading.

coords = Point(whois_obj.longitude, whois_obj.latitude, srid=4326)
address = whois_obj.formatted_address
location_name = (
",".join(address.split(",")[:2]) + f" (Estimated: {ip_address})"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be similar with below name

Suggested change
",".join(address.split(",")[:2]) + f" (Estimated: {ip_address})"
",".join(address.split(",")[:2]) + f" (Estimated Location: {ip_address})"


with self.subTest(
"Test Approximate Location field visible on admin when "
"WHOIS_CONFIGURED True"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"WHOIS_CONFIGURED True"
"WHOIS_CONFIGURED is True"

importlib.reload(config_app_settings)
with self.subTest(
"Test Approximate Location field hidden on admin when "
"WHOIS_CONFIGURED False"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"WHOIS_CONFIGURED False"
"WHOIS_CONFIGURED is False"

Comment on lines 127 to 129
with self.subTest(
"Approximate location task called when last_ip has related WhoIsInfo"
):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure on this but if there is only one sub test, should we create sub tests?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are other subtests called as well in statement above it

@DragnEmperor DragnEmperor force-pushed the issues/1034-fuzzy-location-creation branch from 2d063af to fbd5bb7 Compare July 16, 2025 18:48
@@ -51,6 +52,18 @@ class AbstractWHOISInfo(TimeStampedEditableModel):
blank=True,
help_text=_("CIDR"),
)
latitude = models.FloatField(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use PointField here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we can, I was also think of doing this as these are used for coordinates only

Comment on lines +113 to +133
if not self.is_valid_public_ip_address(new_ip):
return False

if not self.is_whois_enabled:
return False
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I am in favour of renaming the ip_address variable in get_device_whois_info method. I didn't found any other occurence for this.

@@ -220,8 +220,41 @@ def test_whois_model_fields_validation(self):
with self.assertRaises(ValidationError):
self._create_whois_info(asn="InvalidASN")

# Common validation checks for latitude and longitude
latitudes = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about jus this?

cases = [
    ("latitude", 100.0, "Ensure this value is less than or equal to 90.0."),
    ("latitude", -100.0, "Ensure this value is greater than or equal to -90.0."),
    ("longitude", 200.0, "Ensure this value is less than or equal to 180.0."),
    ("longitude", -200.0, "Ensure this value is greater than or equal to -180.0."),
]
for field, value, expected_msg in cases:
    with self.subTest(field=field, value=value):
        with self.assertRaises(ValidationError) as cm:
            kwargs = {field: value}
            self._create_whois_info(**kwargs)
        self.assertEqual(cm.exception.message_dict[field][0], expected_msg)

@@ -1,3 +1,8 @@
from unittest import mock
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let’s ensure we always keep test utilities separate from those used in functional code.

Comment on lines 102 to 149
logger.info(
f"Estimated location saved successfully for {device_pk} for IP: {ip_address}"
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if whois_obj doesn't exist, then it will log that as success which is incorrect. we should handle such cases as well.

Comment on lines 41 to 57
coords = Point(whois_obj.longitude, whois_obj.latitude, srid=4326)
address = whois_obj.formatted_address
location_name = (
",".join(address.split(",")[:2]) + f" (Estimated Location: {ip_address})"
if address
else f"Estimated Location: {ip_address}"
)
# Used to update an existing location if it is estimated
# or create a new one if it doesn't exist
location_defaults = {
"name": location_name,
"type": "outdoor",
"organization_id": device.organization_id,
"is_mobile": False,
"geometry": coords,
"address": address,
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's define this as part of whois model class itself, so that it can be reused via model and have less dependency on this task.

Comment on lines 73 to 74
if add_existing and (not current_location or current_location.is_estimated):
existing_devices_location = (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be separated into a new function called: handle_attach_existing

# If there are multiple devices with same last_ip then we need to inform
# the user to resolve the conflict manually.
if existing_devices_location.count() > 1:
send_whois_task_notification(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here logging an error will be better about multiple devices found

Comment on lines 94 to 130
if current_location and current_location.pk != existing_location.pk:
current_location.delete()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when we will get this case, can you explain a scenario to test it?

Copy link
Member Author

@DragnEmperor DragnEmperor Jul 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was added due to an Issue I was facing while writing tests, which is now resolved. I will update this as i think there might be some changes in this.

Comment on lines 64 to 42
location = Location(**location_defaults, is_estimated=True)
location.full_clean()
location.save()
device_location.location = location
device_location.full_clean()
device_location.save()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should use transaction.atomic here

@@ -51,6 +52,24 @@ class AbstractWHOISInfo(TimeStampedEditableModel):
blank=True,
help_text=_("CIDR"),
)
# latitude = models.FloatField(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this code is commented?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, might have been left during last changes. Will remove this

@DragnEmperor DragnEmperor force-pushed the issues/1034-fuzzy-location-creation branch from b82ff48 to 641a3d9 Compare July 22, 2025 20:22
new_ip_address=new_ip,
)
)
# `add_existing` is `True` to handle the case when WHOIS already exists
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment still relevant?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not, removing this

def is_estimated_location_enabled(self):
"""
Check if the Estimated location feature is enabled.
This does not require to set cache as `is_whois_enabled` already sets it
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a test case for this?

Copy link
Member Author

@DragnEmperor DragnEmperor Jul 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will update the existing test case which asserts cache.get to assert .set is not called as well

triggering the WHOIS lookup automatically.

It accepts an optional flag ``--whois-related`` to exclude devices with
WHOIS records.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be the default, I don't think we need the flag.

@@ -45,6 +45,17 @@ met:
- There is **no existing WHOIS record** for that IP.
- WHOIS lookup is **enabled** for the device's organization.

Handling Existing Devices
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of adding this section here, add it at the bottom of the setup instructions and provide a copy/paste example that includes enabling the virtualenv (for users using ansible-openwisp2).

Point 6 should be to restart the application if using ansible-openwisp2, while docker containers should just be respawned.

Point 7 should be to use the management command.

devices = Device.objects.filter(_is_deactivated=False).exclude(last_ip=None)
devices = devices.only("last_ip")
if options["whois_related"]:
if not app_settings.WHOIS_CONFIGURED:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check should be at the beginning of the command.

@DragnEmperor DragnEmperor force-pushed the issues/1034-fuzzy-location-creation branch from 2dad1f0 to 48d0036 Compare August 1, 2025 05:36
Copy link
Member

@codesankalp codesankalp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The feature is looking great. I did end-to-end testing. Please take a look at my comments below:

if address:
parts = [part.strip() for part in address.split(",")[:2] if part.strip()]
location = ", ".join(parts)
return f"{location} (Estimated Location: {self.ip_address})"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we keep Estimated Location translatable?

Comment on lines +132 to +170
def process_ip_data_and_location(self):
"""
Trigger WHOIS lookup based on the conditions of `_need_whois_lookup`.
Task is triggered on commit to ensure redundant data is not created.
Trigger WHOIS lookup based on the conditions of `_need_whois_lookup`
and also manage estimated locations based on the conditions of
`_need_estimated_location_management`.
Tasks are triggered on commit to ensure redundant data is not created.
"""
if self._need_whois_lookup(self.device.last_ip):
new_ip = self.device.last_ip
if self._need_whois_lookup(new_ip):
transaction.on_commit(
lambda: fetch_whois_details.delay(
device_pk=self.device.pk,
initial_ip_address=self.device._initial_last_ip,
new_ip_address=self.device.last_ip,
new_ip_address=new_ip,
)
)
# To handle the case when WHOIS already exists as in that case
# WHOIS lookup is not triggered but we still need to
# manage estimated locations.
elif self._need_estimated_location_management(new_ip):
transaction.on_commit(
lambda: manage_estimated_locations.delay(
device_pk=self.device.pk, ip_address=new_ip
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

manage_estimated_locations keeps firing repeatedly, even when an estimated location already exists and the device’s IP hasn’t changed. can we ignore this task if ip and location is not changed?

Another thing which i found is delete handler is not working properly as shown in the demo below.

image

video: https://drive.google.com/file/d/1HbgtsxukFQbIPQuqlObTIqS7fLu6NiTh/view?usp=sharing

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first issue is fixed, had to remove the function from DeviceChecksumView.
I cannot replicate the second one as the record is getting deleted on device deletion

WHOIS_Deleted.mp4

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then it might be issue with my system, @devkapilbansal can you please also verify this?

Copy link
Member Author

@DragnEmperor DragnEmperor Aug 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is also a test for deletion of record on device delete, can you please check if that is failing as well?

Edit: last subtest of test_whois_creation

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I will check this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codesankalp @DragnEmperor How can we test the scenario where multiple devices have same last_ip? Any way to do it without router or VM?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I usually follow these steps:

  • Create 2 or more devices from admin
  • Use ngrok tunnel for creating a global link for the local server
  • Open either https://www.proxysite.com/ or https://proxyium.com/ and pass the url to checksum for the device. Selecting the same server will register same IP for the devices.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last time while using using proxium, I believe the IPs were different for same server as well. Will try it once again or with proxysite

Comment on lines 22 to 24
if not app_settings.WHOIS_CONFIGURED:
self.stdout.write("WHOIS must be configured to use this option.")
return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we don't need this check, this management command is separate and doesn't need who is to be configured.

@DragnEmperor DragnEmperor force-pushed the issues/1034-fuzzy-location-creation branch from a9c5fbc to bc837a1 Compare August 21, 2025 16:52
@DragnEmperor DragnEmperor changed the title [feature] Fuzzy location creation [feature] Estimated location creation Aug 28, 2025
@DragnEmperor DragnEmperor force-pushed the issues/1034-fuzzy-location-creation branch from d10ef51 to 0a1c1cc Compare August 29, 2025 04:08
DragnEmperor and others added 4 commits August 29, 2025 10:26
Closes #1034

Signed-off-by: DragnEmperor <dragnemperor@gmail.com>


Closes #1035

Signed-off-by: DragnEmperor <dragnemperor@gmail.com>
Closes #1036

Signed-off-by: DragnEmperor <dragnemperor@gmail.com>
Closes #1028

Signed-off-by: DragnEmperor <dragnemperor@gmail.com>
@DragnEmperor DragnEmperor force-pushed the issues/1034-fuzzy-location-creation branch from 0a1c1cc to 2c1dda6 Compare August 29, 2025 04:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement gsoc Part of a Google Summer of Code project
Development

Successfully merging this pull request may close these issues.

5 participants