Skip to content

Commit

Permalink
Merge pull request #54 from willemarcel/v0.8.3
Browse files Browse the repository at this point in the history
Change "New mapper" evaluation
  • Loading branch information
willemarcel committed Apr 15, 2021
2 parents 592f91e + 15a8ee6 commit 034430c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 26 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Change Log
==========

[0.8.3] - 2021-04-15
* Consider as "New mapper" users with less than 50 changesets
* Remove request to osm-comments-api

[0.8.2] - 2020-10-16
* Replace homura by urllib.request
* Drop Python 2 support
Expand Down
2 changes: 1 addition & 1 deletion osmcha/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# osmcha
__version__ = '0.8.2'
__version__ = '0.8.3'
19 changes: 2 additions & 17 deletions osmcha/changeset.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@
'OSM_USERS_API',
'https://www.openstreetmap.org/api/0.6/user/{user_id}'
)
MAPBOX_USERS_API = environ.get(
'MAPBOX_USERS_API',
'https://osm-comments-api.mapbox.com/api/v1/users/id/{user_id}?extra=true'
)
# information that we get from changeset xml key
# infosrmation that we get from changeset xml key
MANDATORY_TAGS = ['id', 'user', 'uid', 'bbox', 'created_at', 'comments_count']
# fields that will be removed on the Analyse.get_dict() method
FIELDS_TO_REMOVE = [
Expand All @@ -65,19 +61,8 @@ def get_user_details(user_id):
xml_data = ET.fromstring(user_data)[0]
changesets = [i for i in xml_data if i.tag == 'changesets'][0]
blocks = [i for i in xml_data if i.tag == 'blocks'][0]
if int(changesets.get('count')) <= 5:
if int(changesets.get('count')) <= 50:
reasons.append('New mapper')
elif int(changesets.get('count')) <= 30:
url = MAPBOX_USERS_API.format(
user_id=requests.compat.quote(user_id)
)
user_request = requests.get(url)
if user_request.status_code == 200:
mapping_days = int(
user_request.json().get('extra').get('mapping_days')
)
if mapping_days <= 5:
reasons.append('New mapper')
if int(blocks[0].get('count')) > 1:
reasons.append('User has multiple blocks')
except Exception as e:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
],
keywords=['openstreetmap', 'osm', 'QA', 'gis'],
author="Wille Marcel",
author_email='wille@wille.blog.br',
author_email='wille[email protected]',
url='https://github.com/willemarcel/osmcha',
license='GPLv3+',
packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
Expand Down
7 changes: 0 additions & 7 deletions tests/test_mod.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,13 +810,6 @@ def test_changeset_by_another_new_mapper():
assert changeset.is_suspect


def test_changeset_with_6_mapping_days():
changeset = Analyse(13523366)
changeset.full_analysis()
assert 'New mapper' not in changeset.suspicion_reasons
assert not changeset.is_suspect


def test_changeset_by_old_mapper_with_unicode_username():
changeset = Analyse(46790192)
changeset.full_analysis()
Expand Down

0 comments on commit 034430c

Please sign in to comment.