internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: RocketMap/RocketMap

Issue:
Notifications not working in most mobile browsers
## Expected Behavior
Notification received when pokemon is in view
Pokemon jumping
Pokemon tapable to see its details

## Current Behavior
Notification is not received (notifications accepted when accessing map the first time)
Pokemon not jumping
Pokemon is not tapable to see its details

## Possible Solution
Is there a browser setting affecting this?

## Steps to Reproduce (for bugs)
Enable notification for a pokemon type, reload page.
No notification.

## Context

## Your Environment
Android

Affected browsers:
- chrome
- opera
- samsung internet (previous version worked)

Still works in:
- firefox



Discussion:
The problem is that RM use Notification, this function is deprecated in most Mobile Browsers now.
https://github.com/RocketMap/RocketMap/blob/develop/static/js/map.js#L1590

![image](https://cloud.githubusercontent.com/assets/19345417/26673523/7768ef98-46bd-11e7-8fa6-f2af7e66ab3d.png)


So you also get a JS Error. You need a Serviceworker now, on desktop this works fine without a Serviceworker. https://developers.google.com/web/fundamentals/getting-started/codelabs/push-notifications/

I use this plugin on my Map.

https://nickersoft.github.io/push.js/
I understood why it's not working.
But not how to make it work.

Do I need to install a plugin in my browser, modify the RM code, or... something else.
You need to modify the Rocketmap code and register a serviceworker on the line i posted above
Instead of recommending that people edit their own code (which will inevitably lead to problems), we invite you to open a PR with a possible fix.

In the meantime, I've flagged the issue and someone from RM's PR team will pick it up as we work through some more important priorities, unless someone else wants to have some fun implementing it and opening a PR.

Resolving patch:
diff --git a/pogom/app.py b/pogom/app.py
--- a/pogom/app.py
+++ b/pogom/app.py
@@ -5,7 +5,7 @@
 import logging
 
 from flask import Flask, abort, jsonify, render_template, request,\
-    make_response
+    make_response, send_from_directory
 from flask.json import JSONEncoder
 from flask_compress import Compress
 from datetime import datetime
@@ -64,10 +64,15 @@ def __init__(self, import_name, **kwargs):
         self.route("/submit_token", methods=['POST'])(self.submit_token)
         self.route("/get_stats", methods=['GET'])(self.get_account_stats)
         self.route("/robots.txt", methods=['GET'])(self.render_robots_txt)
+        self.route("/serviceWorker.min.js", methods=['GET'])(
+            self.render_service_worker_js)
 
     def render_robots_txt(self):
         return render_template('robots.txt')
 
+    def render_service_worker_js(self):
+        return send_from_directory('static/dist/js', 'serviceWorker.min.js')
+
     def get_bookmarklet(self):
         args = get_args()
         return render_template('bookmarklet.html',


Test patch:
Repository: RocketMap/RocketMap

Issue:
Bug in default status name.
## Expected Behavior
Starting an instance without a status name should not cause RM to crash.

## Current Behavior
Starting an instance without a status name causes RM to crash.

## Possible Solution
RM uses the (integer) process ID as the default status name. This causes the regex test introduced in #2242 to throw an exception.

## Steps to Reproduce (for bugs)
Start a scan instance without a status name.



Discussion:

Resolving patch:
diff --git a/pogom/utils.py b/pogom/utils.py
--- a/pogom/utils.py
+++ b/pogom/utils.py
@@ -442,7 +442,7 @@ def get_args():
     parser.add_argument('-slt', '--stats-log-timer',
                         help='In log view, list per hr stats every X seconds',
                         type=int, default=0)
-    parser.add_argument('-sn', '--status-name', default=os.getpid(),
+    parser.add_argument('-sn', '--status-name', default=str(os.getpid()),
                         help=('Enable status page database update using ' +
                               'STATUS_NAME as main worker name.'))
     parser.add_argument('-spp', '--status-page-password', default=None,


Test patch:
Repository: RocketMap/RocketMap

Issue:
IndexError('list index out of range',)
<!--

  ISSUES ARE NOT FOR SUPPORT!!!
  ISSUES ARE NOT FOR SUPPORT!!!
  ISSUES ARE NOT FOR SUPPORT!!!
  ISSUES ARE NOT FOR SUPPORT!!!
  ISSUES ARE NOT FOR SUPPORT!!!
  ISSUES ARE NOT FOR SUPPORT!!!
  ISSUES ARE NOT FOR SUPPORT!!!
  ISSUES ARE NOT FOR SUPPORT!!!

  Join discord (channel: #help) for support at this link: https://discord.gg/rocketmap
  
  Submit feature requests @ http://vote.devkat.org
  
-->

<!--- Provide a general summary of the issue in the Title above -->

## Expected Behavior
No exceptions

## Current Behavior
```
2017-10-05 08:57:57,286 [  search-worker-44][        search][   ERROR] Map parse failed at XXX,YYY, abandoning location. ZZZ may be banned.. Exception message: IndexError('list index out of range',)
Traceback (most recent call last):
  File "/home/RocketMap/pogom/search.py", line 1011, in search_worker_thread
    scheduler.task_done(status, parsed)
  File "/home/RocketMap/pogom/schedulers.py", line 1108, in task_done
    item = self.queues[0][status['index_of_queue_item']]
IndexError: list index out of range
2017-10-05 08:57:57,320 [  search-worker-44][        search][   ERROR] Exception in search_worker under account ZZZ.
Traceback (most recent call last):
  File "/home/RocketMap/pogom/search.py", line 1037, in search_worker_thread
    if response_dict is not None:
UnboundLocalError: local variable 'response_dict' referenced before assignment
```

## Possible Solution
Catch?

## 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 -->
Its random behavior.

## 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 -->
* Debian GNU/Linux 9 (stretch)
* Python 2.7.13



Discussion:

Resolving patch:
diff --git a/pogom/search.py b/pogom/search.py
--- a/pogom/search.py
+++ b/pogom/search.py
@@ -1007,7 +1007,7 @@ def search_worker_thread(args, account_queue, account_sets, account_failures,
                     parsed = parse_map(args, response_dict, step_location,
                                        dbq, whq, key_scheduler, api, status,
                                        scan_date, account, account_sets)
-                    del response_dict
+
                     scheduler.task_done(status, parsed)
                     if parsed['count'] > 0:
                         status['success'] += 1
@@ -1034,6 +1034,7 @@ def search_worker_thread(args, account_queue, account_sets, account_failures,
                                                            account['username'])
                     log.exception('{}. Exception message: {}'.format(
                         status['message'], repr(e)))
+                finally:
                     if response_dict is not None:
                         del response_dict
 


Test patch:
Repository: RocketMap/RocketMap

Issue:
Location marker can be moved, possibly messing up map experience.
Problem comes from our help channel on Discord.

## Expected Behavior
Gmaps location marker should be static (if `--no-fixed-location` is disabled).

## Current Behavior
It can be moved. Even though it doesn't affect the scanner, it can cause issues (especially on mobile) where the marker gets moved off screen and the map pans towards it.

## Possible Solution
Allow marker to be static, or even disabled.


Discussion:

Resolving patch:
diff --git a/pogom/app.py b/pogom/app.py
--- a/pogom/app.py
+++ b/pogom/app.py
@@ -169,9 +169,7 @@ def fullmap(self):
         if args.on_demand_timeout > 0:
             self.control_flags['on_demand'].clear()
 
-        search_display = True if (args.search_control and
-                                  args.on_demand_timeout <= 0) else False
-
+        search_display = (args.search_control and args.on_demand_timeout <= 0)
         scan_display = False if (args.only_server or args.fixed_location or
                                  args.spawnpoint_scanning) else True
 


Test patch:
Repository: RocketMap/RocketMap

Issue:
Scanned genders are inaccurate
Long story short, there is a discrepancy between the gender returned by GetMapObjects, and the actual gender you get when starting the encounter.

When using IV scanning accounts, the proper gender should easily be retrieved and the record updated - however, it is still using the original gender from the GMO response.

For non-IV scanned species there's no way to ensure accuracy, but when our local Discord server posts scanned results from the RM database, it's still using the original genders as returned by GMO, and not the true ones.

More information not pertinent to RM can be found at my initial write-up [here](https://www.reddit.com/r/TheSilphRoad/comments/7vl7ve/observation_pokémon_change_genders_when/)


Discussion:
Flagging to be checked for now, this definitely does seem to be happening but I'd like a deeper look in the context of the RM code.
A solution could be to use the 'fresh' data from encounters to overwrite the data originally received via GMO.  There seems to be a belief that the encounter data is accurate for gender.
Correct. When you encounter the Pokémon (to get its IVs, for example) you will get the correct gender.  This is pertinent in the official game for species with visible form differences, e.g. Magikarp, Sneasel, Scyther and so on.

You can also encounter it with the level 1s and get the same gender data, but that would waste a lot more hashing requests, and is probably unnecessary.  I would vote to just overwrite the gender value with the data returned by the IV scanning accounts - if you don't scan IVs the gender might not match and/or just not known at all in that case.
Tagged as "help wanted" instead of "to be checked": overwriting the gender data is a good middle ground for this problem, especially since encountering with lv1's would immensely increase the request count, and nothing guarantees that gender will stay the same for all levels.

Resolving patch:
diff --git a/pogom/models.py b/pogom/models.py
--- a/pogom/models.py
+++ b/pogom/models.py
@@ -2055,7 +2055,8 @@ def parse_map(args, map_dict, scan_coords, scan_location, db_update_queue,
                     'height': pokemon_info.height_m,
                     'weight': pokemon_info.weight_kg,
                     'cp': pokemon_info.cp,
-                    'cp_multiplier': pokemon_info.cp_multiplier
+                    'cp_multiplier': pokemon_info.cp_multiplier,
+                    'gender': pokemon_info.pokemon_display.gender
                 })
 
             if 'pokemon' in args.wh_types:


Test patch:
Repository: jazzband/django-simple-history

Issue:
templates missing from pypi packages
The templates directory is missing from the tarballs uploaded to pypi.

```
from simple_history.admin import SimpleHistoryAdmin
admin.site.register(MyModel, SimpleHistoryAdmin)
```

there is a history button in the admin page but it fails miserably to find the templates.



Discussion:
I just released version 1.2.2 which fixes this packaging bug.

Thanks for reporting this.


Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -3,7 +3,7 @@
 
 setup(
     name='django-simple-history',
-    version='1.2.2',
+    version='1.2.3',
     description='Store model history and view/revert changes from admin site.',
     long_description='\n'.join((
         open('README.rst').read(),
@@ -25,5 +25,6 @@
         "License :: OSI Approved :: BSD License",
     ],
     tests_require=["Django>=1.3", "webtest", "django-webtest"],
+    include_package_data=True,
     test_suite='runtests.main',
 )


Test patch:
Repository: jazzband/django-simple-history

Issue:
history_user error during usage of simple_history.middleware.HistoryRequestMiddleware
Hello!
I've written some automatic tests with WebTest. During execution of testsuite test data is generated automatically (some objects are created dynamically). If I don't use simple_history.middleware.HistoryRequestMiddleware, than all tests run successfully. If I use it, than the following error occurs:
ValueError(u'Cannot assign "<django.utils.functional.SimpleLazyObject object at 0x982332c>": "HistoricalActor.history_user" must be a "User" instance.

Could you, please, tell me the direction on digging for solving such problem.



Discussion:

Resolving patch:
diff --git a/simple_history/models.py b/simple_history/models.py
--- a/simple_history/models.py
+++ b/simple_history/models.py
@@ -233,9 +233,11 @@ def get_history_user(self, instance):
             return instance._history_user
         except AttributeError:
             try:
-                return self.thread.request.user
+                if self.thread.request.user.is_authenticated():
+                    return self.thread.request.user
+                return None
             except AttributeError:
-                return
+                return None
 
 
 class ForeignKeyMixin(object):


Test patch:
diff --git a/simple_history/tests/tests/test_admin.py b/simple_history/tests/tests/test_admin.py
--- a/simple_history/tests/tests/test_admin.py
+++ b/simple_history/tests/tests/test_admin.py
@@ -185,6 +185,20 @@ def test_middleware_saves_user(self):
             self.assertEqual(historical_poll.history_user, self.user,
                              "Middleware should make the request available to "
                              "retrieve history_user.")
+                            
+    def test_middleware_anonymous_user(self):
+        overridden_settings = {
+            'MIDDLEWARE_CLASSES':
+                settings.MIDDLEWARE_CLASSES
+                + ['simple_history.middleware.HistoryRequestMiddleware'],
+        }
+        with override_settings(**overridden_settings):
+            self.app.get(reverse('admin:index'))
+            poll = Poll.objects.create(question="why?", pub_date=today)
+            historical_poll = poll.history.all()[0]
+            self.assertEqual(historical_poll.history_user, None,
+                             "Middleware request user should be able to "
+                             "be anonymous.")
 
     def test_other_admin(self):
         """Test non-default admin instances.
Repository: jazzband/django-simple-history

Issue:
Do NOT delete the historical elements when a user is deleted.
Hi there,

We are porting over our simple-history to your and I'm comparing notes.  This one burned us awhile ago that when a user is deleted you probably don't want the history of associated element to CASCADE delete.  I have a pull request coming for this.



Discussion:

Resolving patch:
diff --git a/simple_history/models.py b/simple_history/models.py
--- a/simple_history/models.py
+++ b/simple_history/models.py
@@ -167,7 +167,8 @@ def get_instance(self):
             'history_id': models.AutoField(primary_key=True),
             'history_date': models.DateTimeField(),
             'history_user': models.ForeignKey(
-                user_model, null=True, related_name=self.user_related_name),
+                user_model, null=True, related_name=self.user_related_name,
+                on_delete=models.SET_NULL),
             'history_type': models.CharField(max_length=1, choices=(
                 ('+', 'Created'),
                 ('~', 'Changed'),


Test patch:
diff --git a/simple_history/tests/tests/test_admin.py b/simple_history/tests/tests/test_admin.py
--- a/simple_history/tests/tests/test_admin.py
+++ b/simple_history/tests/tests/test_admin.py
@@ -219,3 +219,19 @@ def test_other_admin(self):
         self.app.get(history_url)
         change_url = get_history_url(state, 0, site="other_admin")
         self.app.get(change_url)
+
+    def test_deleteting_user(self):
+        """Test deletes of a user does not cascade delete the history"""
+        self.login()
+        poll = Poll(question="why?", pub_date=today)
+        poll._history_user = self.user
+        poll.save()
+
+        historical_poll = poll.history.all()[0]
+        self.assertEqual(historical_poll.history_user, self.user)
+
+        self.user.delete()
+
+        historical_poll = poll.history.all()[0]
+        self.assertEqual(historical_poll.history_user, None)
+
Repository: jazzband/django-simple-history

Issue:
View deleted instances from admin page
The `SimpleHistoryAdmin` allows the history of a instance that still exists to bee seen. It would be great if there would be a way to view a list of deleted instances, and see their histories.



Discussion:
History for all instances (including deleted ones) can be queried [on the model class](https://django-simple-history.readthedocs.org/en/latest/usage.html#querying-history-on-a-model-class) like this:

```
Choice.history.filter(history_type='-')  # Deleted choices
```

I agree that this might be a useful feature for the admin interface.

Pull requests welcome.

+1 !


Resolving patch:
diff --git a/simple_history/admin.py b/simple_history/admin.py
--- a/simple_history/admin.py
+++ b/simple_history/admin.py
@@ -6,6 +6,7 @@
 from django.contrib.admin import helpers
 from django.contrib.contenttypes.models import ContentType
 from django.core.urlresolvers import reverse
+from django.http import Http404
 from django.shortcuts import get_object_or_404, render
 from django.utils.text import capfirst
 from django.utils.html import mark_safe
@@ -56,7 +57,13 @@ def history_view(self, request, object_id, extra_context=None):
         object_id = unquote(object_id)
         action_list = history.filter(**{pk_name: object_id})
         # If no history was found, see whether this object even exists.
-        obj = get_object_or_404(model, pk=object_id)
+        try:
+            obj = model.objects.get(**{pk_name: object_id})
+        except model.DoesNotExist:
+            try:
+                obj = action_list.latest('history_date').instance
+            except action_list.model.DoesNotExist:
+                raise Http404
         content_type = ContentType.objects.get_by_natural_key(
             *USER_NATURAL_KEY)
         admin_user_view = 'admin:%s_%s_change' % (content_type.app_label,


Test patch:
diff --git a/simple_history/tests/tests/test_admin.py b/simple_history/tests/tests/test_admin.py
--- a/simple_history/tests/tests/test_admin.py
+++ b/simple_history/tests/tests/test_admin.py
@@ -250,3 +250,13 @@ def test_missing_one_to_one(self):
         manager.delete()
         response = self.app.get(get_history_url(employee, 0))
         self.assertEqual(response.status_code, 200)
+
+    def test_history_deleted_instance(self):
+        """Ensure history page can be retrieved even for deleted instances"""
+        self.login()
+        employee = Employee.objects.create()
+        employee_pk = employee.pk
+        employee.delete()
+        employee.pk = employee_pk
+        response = self.app.get(get_history_url(employee))
+        self.assertEqual(response.status_code, 200)
Repository: jazzband/django-simple-history

Issue:
Change ugettext to ugettext_lazy?
I am using Django signals. This involves putting some imports into the app __init__ file. 

After adding django-simple-history to one of my models, I get this error when starting the dev server:

`django.core.exceptions.AppRegistryNotReady: The translation infrastructure cannot be initialized before the apps registry is ready. Check that you don't make non-lazy gettext calls at import time.`

I believe this error is caused by the ugettext calls in simple_history.models. Is there a reason you chose to use ugettext instead of ugettext_lazy?




Discussion:
@cuducos do you have any idea?
I'm sorry about that, @cwurld – no special reason, and I wasn't aware of that issue with signals. I see no problem in changing it to`ugettext_lazy`, @leportella – I just cannot handle that this week, so anyone willing to jump in is more than welcomed ; )
> I am using Django signals. This involves putting some imports into the app `__init__` file.

Note that this is fixed in recent Django version with AppConfig: you can import and connect your signal handlers in YourAppConfig.ready, where the app registry is all ready.

This is not to say that module-level gettext calls should not be lazy: that’s a good thing to fix independently, since you want the translations to be resolved at request time only.

Resolving patch:
diff --git a/simple_history/models.py b/simple_history/models.py
--- a/simple_history/models.py
+++ b/simple_history/models.py
@@ -11,7 +11,7 @@
 from django.utils import six
 from django.utils.encoding import python_2_unicode_compatible, smart_text
 from django.utils.timezone import now
-from django.utils.translation import string_concat, ugettext as _
+from django.utils.translation import string_concat, ugettext_lazy as _
 
 from . import exceptions
 from .manager import HistoryDescriptor


Test patch:
Repository: jazzband/django-simple-history

Issue:
Registration cycle with custom and historized User model and simple-history 2.5.0
**Describe the bug**
I have custom user model in module which imports simple_history.models (I think it is common to register historical records in models.py with custom user model.) It worked with simple-history 2.4.0. 

But there is new call of get_user_model on class level (https://github.com/treyhunner/django-simple-history/commit/372632779592b026756cbfd83fc8712afb7a6978). It raises exception:

 File ".../models.py", line ..., in <module>
    import simple_history.models
  File ".../simple_history/models.py", line 29, in <module>
    User = get_user_model()
  File ".../django/contrib/auth/__init__.py", line 170, in get_user_model
    "AUTH_USER_MODEL refers to model '%s' that has not been installed" % settings.AUTH_USER_MODEL
django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to model '....User' that has not been installed

Class level User variable is used only once - so it is quite simple to call get_user_model in get_extra_fields method (one line down :)) - it solves problem.

**To Reproduce**
1. Define custom user model and import simple_history.models in models.py (for historization of users).
2. Set AUTH_USER_MODEL to this model.

**Environment:**
 - Django Simple History Version: 2.5.0
 - Django Version: 2.1.2



Discussion:
Thanks for catching the @pm13. I'll try to merge a bugfix ASAP. Can you describe a little more clearly what fixed the issue? I'm looking at #435 now and also looking at https://docs.djangoproject.com/en/1.11/topics/auth/customizing/#referencing-the-user-model. @ThePumpingLemma think we should just revert that commit based on django docs?

Resolving patch:
diff --git a/simple_history/__init__.py b/simple_history/__init__.py
--- a/simple_history/__init__.py
+++ b/simple_history/__init__.py
@@ -1,6 +1,6 @@
 from __future__ import unicode_literals
 
-__version__ = '2.5.0'
+__version__ = '2.5.1'
 
 
 def register(
diff --git a/simple_history/models.py b/simple_history/models.py
--- a/simple_history/models.py
+++ b/simple_history/models.py
@@ -8,8 +8,7 @@
 from django.apps import apps
 from django.conf import settings
 from django.contrib import admin
-from django.contrib.auth import get_user_model
-from django.db import models, router
+from django.db import models
 from django.db.models import Q
 from django.db.models.fields.proxy import OrderWrt
 from django.urls import reverse
@@ -26,7 +25,6 @@
     post_create_historical_record,
 )
 
-User = get_user_model()
 registered_models = {}
 
 
@@ -220,7 +218,9 @@ def copy_fields(self, model):
     def get_extra_fields(self, model, fields):
         """Return dict of extra fields added to the historical record model"""
 
-        user_model = self.user_model or User
+        user_model = self.user_model or getattr(
+            settings, 'AUTH_USER_MODEL', 'auth.User'
+        )
 
         def revert_url(self):
             """URL for this change in the default admin site."""


Test patch: