Skip to content

Commit 993b867

Browse files
authored
Merge pull request #82 from maxmind/dlieou/static-ip-score
added static_ip_score to the API
2 parents 2a9f2cd + c834dc4 commit 993b867

File tree

7 files changed

+28
-5
lines changed

7 files changed

+28
-5
lines changed

HISTORY.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ History
1515
* Python 3.3 and 3.4 are no longer supported.
1616
* Updated documentation of anonymizer attributes - ``is_anonymous_vpn`` and
1717
``is_hosting_provider`` - to be more descriptive.
18-
* Added support for ``user_count`` trait for the GeoIP2 Precision webservice.
18+
* Added support for the ``user_count`` trait for the GeoIP2 Precision webservice.
19+
* Added the ``static_ip_score`` attribute to ``geoip2.record.Traits`` for
20+
GeoIP2 Precision Insights. This is a float which indicates how static or dynamic
21+
an IP address is.
1922

2023
2.9.0 (2018-05-25)
2124
++++++++++++++++++

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
# General information about the project.
4949
project = 'geoip2'
50-
copyright = '2013-2018, MaxMind, Inc.'
50+
copyright = '2013-2019, MaxMind, Inc.'
5151

5252
# The version info for the project you're documenting, acts as replacement for
5353
# |version| and |release|, also used in various other places throughout the

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ Indices and tables
3838
* :ref:`modindex`
3939
* :ref:`search`
4040

41-
:copyright: (c) 2013-2018 by MaxMind, Inc.
41+
:copyright: (c) 2013-2019 by MaxMind, Inc.
4242
:license: Apache License, Version 2.0
4343

geoip2/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
__version__ = '2.9.0'
55
__author__ = 'Gregory Oschwald'
66
__license__ = 'Apache License, Version 2.0'
7-
__copyright__ = 'Copyright (c) 2013-2018 Maxmind, Inc.'
7+
__copyright__ = 'Copyright (c) 2013-2019 Maxmind, Inc.'

geoip2/records.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,20 @@ class Traits(Record):
684684
685685
:type: unicode
686686
687+
.. attribute:: static_ip_score
688+
689+
An indicator of how static or dynamic an IP address is. The value ranges
690+
from 0 to 99.99 with higher values meaning a greater static association.
691+
For example, many IP addresses with a user_type of cellular have a
692+
lifetime under one. Static Cable/DSL IPs typically have a lifetime above
693+
thirty.
694+
695+
This indicator can be useful for deciding whether an IP address represents
696+
the same user over time. This attribute is only available from GeoIP2
697+
Precision Insights.
698+
699+
:type: float
700+
687701
.. attribute:: user_count
688702
689703
The estimated number of users sharing the IP/network during the past 24
@@ -738,6 +752,7 @@ def __init__(self,
738752
network=None,
739753
organization=None,
740754
prefix_len=None,
755+
static_ip_score=None,
741756
user_count=None,
742757
user_type=None,
743758
**_):
@@ -755,6 +770,7 @@ def __init__(self,
755770
self.is_tor_exit_node = is_tor_exit_node
756771
self.isp = isp
757772
self.organization = organization
773+
self.static_ip_score = static_ip_score
758774
self.user_type = user_type
759775
self.user_count = user_count
760776
self.ip_address = ip_address

tests/models_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ def test_insights_full(self):
104104
'isp': 'Comcast',
105105
'network_speed': 'cable/DSL',
106106
'organization': 'Blorg',
107+
'static_ip_score': 1.3,
107108
'user_count': 2,
108109
'user_type': 'college',
109110
},
@@ -183,8 +184,8 @@ def test_insights_full(self):
183184
self.assertIs(model.traits.is_public_proxy, True)
184185
self.assertIs(model.traits.is_satellite_provider, True)
185186
self.assertIs(model.traits.is_tor_exit_node, True)
186-
187187
self.assertEqual(model.traits.user_count, 2)
188+
self.assertEqual(model.traits.static_ip_score, 1.3)
188189

189190
def test_insights_min(self):
190191
model = geoip2.models.Insights({'traits': {'ip_address': '5.6.7.8'}})

tests/webservice_test.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def setUp(self):
6464
# JSON from the server
6565
insights = copy.deepcopy(country)
6666
insights['traits']['user_count'] = 2
67+
insights['traits']['static_ip_score'] = 1.3
6768

6869
def _content_type(self, endpoint):
6970
return ('application/vnd.maxmind.com-' + endpoint +
@@ -290,6 +291,8 @@ def test_insights_ok(self, mock):
290291
'return value of client.insights')
291292
self.assertEqual(insights.traits.network,
292293
compat_ip_network('1.2.3.0/24'), 'network')
294+
self.assertEqual(insights.traits.static_ip_score, 1.3,
295+
'static_ip_score is 1.3')
293296
self.assertEqual(insights.traits.user_count, 2, 'user_count is 2')
294297

295298
def test_named_constructor_args(self):

0 commit comments

Comments
 (0)