diff --git a/pogom/models.py b/pogom/models.py index 70ec467395..f2af712238 100644 --- a/pogom/models.py +++ b/pogom/models.py @@ -40,7 +40,7 @@ flaskDb = FlaskDB() cache = TTLCache(maxsize=100, ttl=60 * 5) -db_schema_version = 28 +db_schema_version = 29 class MyRetryDB(RetryOperationalError, PooledMySQLDatabase): @@ -437,6 +437,7 @@ class Gym(LatLongModel): total_cp = SmallIntegerField() last_modified = DateTimeField(index=True) last_scanned = DateTimeField(default=datetime.utcnow, index=True) + is_in_battle = BooleanField(default=False) class Meta: indexes = ((('latitude', 'longitude'), False),) @@ -565,7 +566,8 @@ def get_gym(id): Gym.longitude, Gym.last_modified, Gym.last_scanned, - Gym.total_cp) + Gym.total_cp, + Gym.is_in_battle) .join(GymDetails, JOIN.LEFT_OUTER, on=(Gym.gym_id == GymDetails.gym_id)) .where(Gym.gym_id == id) @@ -2207,7 +2209,9 @@ def parse_map(args, map_dict, scan_coords, scan_location, db_update_queue, 'last_modified': f.last_modified_timestamp_ms, 'raid_active_until': - raid_active_until + raid_active_until, + 'is_in_battle': + f.is_in_battle })) gyms[f.id] = { 'gym_id': @@ -2231,7 +2235,8 @@ def parse_map(args, map_dict, scan_coords, scan_location, db_update_queue, 'last_modified': datetime.utcfromtimestamp( f.last_modified_timestamp_ms / 1000.0), - + 'is_in_battle': + f.is_in_battle } if not args.no_raids and f.type == 0: @@ -3549,6 +3554,13 @@ def database_migrate(db, old_ver): SmallIntegerField(null=True)) ) + if old_ver < 29: + migrate( + # Add `is_in_battle` column to `gym` + migrator.add_column('gym', 'is_in_battle', + BooleanField(null=False, default=False)) + ) + # Always log that we're done. log.info('Schema upgrade complete.') return True diff --git a/static/js/map.js b/static/js/map.js index 98ac112f1a..3529af021a 100644 --- a/static/js/map.js +++ b/static/js/map.js @@ -1217,21 +1217,29 @@ function updateGymMarker(item, marker) { } marker.setIcon({ url: markerImage, - scaledSize: new google.maps.Size(48, 48) + scaledSize: new google.maps.Size(48, 48), + labelOrigin: new google.maps.Point(15, 12) }) marker.setZIndex(google.maps.Marker.MAX_ZINDEX + 1) } else if (hasActiveRaid && raidLevelVisible && showRaidSetting) { marker.setIcon({ url: 'static/images/gym/' + gymTypes[item.team_id] + '_' + getGymLevel(item) + '_' + item['raid']['level'] + '.png', - scaledSize: new google.maps.Size(48, 48) + scaledSize: new google.maps.Size(48, 48), + labelOrigin: new google.maps.Point(15, 12) }) } else { marker.setIcon({ url: 'static/images/gym/' + gymTypes[item.team_id] + '_' + getGymLevel(item) + '.png', - scaledSize: new google.maps.Size(48, 48) + scaledSize: new google.maps.Size(48, 48), + labelOrigin: new google.maps.Point(15, 12) }) marker.setZIndex(1) } + if (item.is_in_battle) { + marker.setLabel({ text: '⚔', fontSize: '16px' }) + } else { + marker.setLabel(null) + } marker.infoWindow.setContent(gymLabel(item)) return marker }