Repository: RocketMap/RocketMap

Issue:
Duplicate pokemon in gym lable again
<!--- Provide a general summary of the issue in the Title above -->
https://github.com/RocketMap/RocketMap/pull/1853 was done to fix the sidebar and label but only seemed to fix sidebar


## Expected Behavior
only count the pokemon once

## Current Behavior
![gym2](https://cloud.githubusercontent.com/assets/8204684/23345060/84b87232-fc7f-11e6-9a8e-ef276f6eb96e.png)



## Steps to Reproduce (for bugs)
<!--- Provide a link to a live example, or an unambiguous set of steps to -->
<!--- reproduce this bug. Include code to reproduce, if relevant -->
1.
2.
3.
4.

## Context
<!--- How has this issue affected you? What are you trying to accomplish? -->
<!--- Providing context helps us come up with a solution that is most useful in the real world -->

## Your Environment
<!--- Include as many relevant details about the environment you experienced the bug in -->
* Version used: latest dev
* Environment name and version (e.g. Python 2.7):
* Operating System and version (desktop or mobile):

Duplicate pokemon in gym lable again
<!--- Provide a general summary of the issue in the Title above -->
https://github.com/RocketMap/RocketMap/pull/1853 was done to fix the sidebar and label but only seemed to fix sidebar


## Expected Behavior
only count the pokemon once

## Current Behavior
![gym2](https://cloud.githubusercontent.com/assets/8204684/23345060/84b87232-fc7f-11e6-9a8e-ef276f6eb96e.png)



## Steps to Reproduce (for bugs)
<!--- Provide a link to a live example, or an unambiguous set of steps to -->
<!--- reproduce this bug. Include code to reproduce, if relevant -->
1.
2.
3.
4.

## Context
<!--- How has this issue affected you? What are you trying to accomplish? -->
<!--- Providing context helps us come up with a solution that is most useful in the real world -->

## Your Environment
<!--- Include as many relevant details about the environment you experienced the bug in -->
* Version used: latest dev
* Environment name and version (e.g. Python 2.7):
* Operating System and version (desktop or mobile):



Discussion:
Add `.distinct()` above this line https://github.com/RocketMap/RocketMap/blob/develop/pogom/models.py#L616
and see whether this fixes your gym issue
It does seem to have fixed it, i shall monitor it over a few days and let you know if the error returns
@BrownSlaughter  You need to delect the gym in db and wait for be scan again and check.
I cleared my db a day ago and this has definitely fixed the issue, thanks Obihoernchen 
Add `.distinct()` above this line https://github.com/RocketMap/RocketMap/blob/develop/pogom/models.py#L616
and see whether this fixes your gym issue
It does seem to have fixed it, i shall monitor it over a few days and let you know if the error returns
@BrownSlaughter  You need to delect the gym in db and wait for be scan again and check.
I cleared my db a day ago and this has definitely fixed the issue, thanks Obihoernchen 

Resolving patch:
diff --git a/pogom/models.py b/pogom/models.py
--- a/pogom/models.py
+++ b/pogom/models.py
@@ -613,6 +613,7 @@ def get_gyms(swLat, swLng, neLat, neLng, timestamp=0, oSwLat=None,
                        .where(GymMember.gym_id << gym_ids)
                        .where(GymMember.last_scanned > Gym.last_modified)
                        .order_by(GymMember.gym_id, GymPokemon.cp)
+                       .distinct()
                        .dicts())
 
             for p in pokemon:


Test patch: