internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: googleapis/python-bigquery

Issue:
Add slot_ms to the Python QueryPlanEntry class
Within our library, we have a class called [QueryPlanEntry.](https://cloud.google.com/python/docs/reference/bigquery/latest/google.cloud.bigquery.job.QueryPlanEntry).  This class models the data found in a BigQuery Job (called ExplainQueryStage).  The description of the BigQuery data can be found [here](https://cloud.google.com/bigquery/docs/reference/rest/v2/Job#explainquerystage).  When we compare the fields, we are finding that there is an important one missing.

In ExplainQueryStage we have a field called "slotMs" which I take to be the slot milliseconds consumed by the given stage.  When we look at the corresponding Python QueryPlanEntry, we do not find that field exposed as a property.

This issue asks for consideration for adding that property.

A quick examination makes me feel that the change might be made [here](https://github.com/googleapis/python-bigquery/blob/main/google/cloud/bigquery/job/query.py#L2030).



Discussion:

Resolving patch:
diff --git a/google/cloud/bigquery/job/query.py b/google/cloud/bigquery/job/query.py
--- a/google/cloud/bigquery/job/query.py
+++ b/google/cloud/bigquery/job/query.py
@@ -2263,6 +2263,11 @@ def steps(self):
             for step in self._properties.get("steps", [])
         ]
 
+    @property
+    def slot_ms(self):
+        """Optional[int]: Slot-milliseconds used by the stage."""
+        return _helpers._int_or_none(self._properties.get("slotMs"))
+
 
 class TimelineEntry(object):
     """TimelineEntry represents progress of a query job at a particular


Test patch:
diff --git a/tests/unit/job/test_query_stats.py b/tests/unit/job/test_query_stats.py
--- a/tests/unit/job/test_query_stats.py
+++ b/tests/unit/job/test_query_stats.py
@@ -261,6 +261,7 @@ class TestQueryPlanEntry(_Base):
     STATUS = "STATUS"
     SHUFFLE_OUTPUT_BYTES = 1024
     SHUFFLE_OUTPUT_BYTES_SPILLED = 1
+    SLOT_MS = 25
 
     START_RFC3339_MICROS = "2018-04-01T00:00:00.000000Z"
     END_RFC3339_MICROS = "2018-04-01T00:00:04.000000Z"
@@ -305,6 +306,7 @@ def test_from_api_repr_empty(self):
         self.assertIsNone(entry.shuffle_output_bytes)
         self.assertIsNone(entry.shuffle_output_bytes_spilled)
         self.assertEqual(entry.steps, [])
+        self.assertIsNone(entry.slot_ms)
 
     def test_from_api_repr_normal(self):
         from google.cloud.bigquery.job import QueryPlanEntryStep
@@ -348,6 +350,7 @@ def test_from_api_repr_normal(self):
                     "substeps": TestQueryPlanEntryStep.SUBSTEPS,
                 }
             ],
+            "slotMs": self.SLOT_MS,
         }
         klass = self._get_target_class()
 
@@ -366,6 +369,7 @@ def test_from_api_repr_normal(self):
         self.assertEqual(entry.records_written, self.RECORDS_WRITTEN)
         self.assertEqual(entry.status, self.STATUS)
         self.assertEqual(entry.steps, steps)
+        self.assertEqual(entry.slot_ms, self.SLOT_MS)
 
     def test_start(self):
         from google.cloud._helpers import _RFC3339_MICROS
Repository: googleapis/python-bigquery

Issue:
Extend the OTEL traces to track bytes billed and bytes processed
Extend OTEL traces to track bytes billed and bytes processed. Allowing developers to see how much data and cost was consumed as part of BigQueryJob trace 


Discussion:

Resolving patch:
diff --git a/google/cloud/bigquery/opentelemetry_tracing.py b/google/cloud/bigquery/opentelemetry_tracing.py
--- a/google/cloud/bigquery/opentelemetry_tracing.py
+++ b/google/cloud/bigquery/opentelemetry_tracing.py
@@ -153,4 +153,12 @@ def _set_job_attributes(job_ref):
     if job_ref.num_child_jobs is not None:
         job_attributes["num_child_jobs"] = job_ref.num_child_jobs
 
+    total_bytes_billed = getattr(job_ref, "total_bytes_billed", None)
+    if total_bytes_billed is not None:
+        job_attributes["total_bytes_billed"] = total_bytes_billed
+
+    total_bytes_processed = getattr(job_ref, "total_bytes_processed", None)
+    if total_bytes_processed is not None:
+        job_attributes["total_bytes_processed"] = total_bytes_processed
+
     return job_attributes


Test patch:
diff --git a/tests/unit/test_opentelemetry_tracing.py b/tests/unit/test_opentelemetry_tracing.py
--- a/tests/unit/test_opentelemetry_tracing.py
+++ b/tests/unit/test_opentelemetry_tracing.py
@@ -142,6 +142,8 @@ def test_default_job_attributes(setup):
         "timeEnded": ended_time.isoformat(),
         "hasErrors": True,
         "state": "some_job_state",
+        "total_bytes_billed": 42,
+        "total_bytes_processed": 13,
     }
     with mock.patch("google.cloud.bigquery.job._AsyncJob") as test_job_ref:
         test_job_ref.job_id = "test_job_id"
@@ -154,6 +156,8 @@ def test_default_job_attributes(setup):
         test_job_ref.ended = ended_time
         test_job_ref.error_result = error_result
         test_job_ref.state = "some_job_state"
+        test_job_ref.total_bytes_billed = 42
+        test_job_ref.total_bytes_processed = 13
 
         with opentelemetry_tracing.create_span(
             TEST_SPAN_NAME, attributes=TEST_SPAN_ATTRIBUTES, job_ref=test_job_ref
@@ -180,6 +184,8 @@ def test_optional_job_attributes(setup):
         test_job_ref.state = "some_job_state"
         test_job_ref.num_child_jobs = None
         test_job_ref.parent_job_id = None
+        test_job_ref.total_bytes_billed = None
+        test_job_ref.total_bytes_processed = None
 
         with opentelemetry_tracing.create_span(
             TEST_SPAN_NAME, attributes=TEST_SPAN_ATTRIBUTES, job_ref=test_job_ref
Repository: kartoza/prj.app

Issue:
Wrong links to images from entry page
If I open an entry page, for example 
    http://changelog.linfiniti.com/qgis/2.8/entry/more-responsive-browser/ and then click on the image I get server error 404 because the link is pointing to 
    /qgis/2.8/entry/<entry name>/images/entries/<hash>.<ext>
instead of 
    /media/images/entries/<hash>.<ext>



Discussion:
Note that it works fine if you go in via:

http://changelog.linfiniti.com/qgis/version/2.8/

Then click on the image.

@ismailsunni we need to get rid of all that middleware black magick and make our navitation system much simpler.


Resolving patch:
diff --git a/django_project/core/settings/base.py b/django_project/core/settings/base.py
--- a/django_project/core/settings/base.py
+++ b/django_project/core/settings/base.py
@@ -89,6 +89,7 @@
 TEMPLATE_CONTEXT_PROCESSORS = (
     'django.contrib.auth.context_processors.auth',
     'django.core.context_processors.request',
+    'django.core.context_processors.media',
     'core.context_processors.add_intercom_app_id'
 )
 
diff --git a/django_project/vota/models/ballot.py b/django_project/vota/models/ballot.py
--- a/django_project/vota/models/ballot.py
+++ b/django_project/vota/models/ballot.py
@@ -108,7 +108,7 @@ class Ballot(AuditedModel):
 
     open_from = models.DateTimeField(
         help_text=_('Date the ballot opens'),
-        default=timezone.now()
+        default=timezone.now
     )
 
     closes = models.DateTimeField(


Test patch:
Repository: kartoza/prj.app

Issue:
We should add Rischan to the email recipients list for projecta errors



Discussion:

Resolving patch:
diff --git a/django_project/core/settings/base.py b/django_project/core/settings/base.py
--- a/django_project/core/settings/base.py
+++ b/django_project/core/settings/base.py
@@ -7,7 +7,8 @@
 from .utils import absolute_path
 
 ADMINS = (
-    ('Tim Sutton', 'tim@linfiniti.com'),
+    ('Tim Sutton', 'tim@kartoza.com'),
+    ('Rischan Mafrur', 'rischan@kartoza.com')
 )
 SERVER_EMAIL = 'tim@linfiniti.com'
 EMAIL_HOST = 'localhost'
@@ -19,7 +20,7 @@
 # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
 # although not all choices may be available on all operating systems.
 # In a Windows environment this must be set to your system time zone.
-TIME_ZONE = 'America/Chicago'
+TIME_ZONE = 'Africa/Johannesburg'
 
 # Language code for this installation. All choices can be found here:
 # http://www.i18nguy.com/unicode/language-identifiers.html


Test patch:
Repository: kartoza/prj.app

Issue:
Permalink to a feature is not working.
The permalink to a feature does not work. For instance `http://changelog.linfiniti.com/qgis/version/2.10/#275` does not scroll to the anchor.

Moreover,if we click on the anchor, the webbrowser doesn't keep the link.



Discussion:

Resolving patch:
diff --git a/django_project/core/settings/base.py b/django_project/core/settings/base.py
--- a/django_project/core/settings/base.py
+++ b/django_project/core/settings/base.py
@@ -108,6 +108,7 @@
 )
 
 ROOT_URLCONF = 'core.urls'
+GRAPPELLI_ADMIN_TITLE = ''
 
 # Python dotted path to the WSGI application used by Django's runserver.
 WSGI_APPLICATION = 'core.wsgi.application'
diff --git a/django_project/core/settings/contrib.py b/django_project/core/settings/contrib.py
--- a/django_project/core/settings/contrib.py
+++ b/django_project/core/settings/contrib.py
@@ -5,6 +5,10 @@
 from .base import *  # noqa
 
 # Extra installed apps
+INSTALLED_APPS = (
+    'grappelli',
+) + INSTALLED_APPS
+
 INSTALLED_APPS += (
     # 'raven.contrib.django',  # enable Raven plugin
     'crispy_forms',
diff --git a/django_project/core/urls.py b/django_project/core/urls.py
--- a/django_project/core/urls.py
+++ b/django_project/core/urls.py
@@ -29,6 +29,7 @@
 ]
 
 urlpatterns += i18n_patterns(
+    url(r'^grappelli/', include('grappelli.urls')),
     url(r'^site-admin/', include(admin.site.urls)),
     url(r'^', include('base.urls')),
     url(r'^', include('changes.urls')),


Test patch:
Repository: kartoza/prj.app

Issue:
rst export eats utf chars
Characters like ü are eaten in the rst export

Jürgen Fischer becomes Jrgen Fischer etc



Discussion:

Resolving patch:
diff --git a/django_project/changes/views/version.py b/django_project/changes/views/version.py
--- a/django_project/changes/views/version.py
+++ b/django_project/changes/views/version.py
@@ -493,7 +493,7 @@ def render_to_response(self, context, **response_kwargs):
         # convert the html to rst
         converted_doc = pypandoc.convert(
             document.rendered_content.encode(
-                'ascii', 'ignore'), 'rst', format='html')
+                'utf8', 'ignore'), 'rst', format='html')
         converted_doc = converted_doc.replace('/media/images/', 'images/')
 
         # prepare the ZIP file


Test patch:
Repository: kartoza/prj.app

Issue:
Menus not working on live site
I have deployed everything to the live site. The menus are not working for me there. Please investigate and fix asap.



Discussion:

Resolving patch:
diff --git a/django_project/core/settings/contrib.py b/django_project/core/settings/contrib.py
--- a/django_project/core/settings/contrib.py
+++ b/django_project/core/settings/contrib.py
@@ -77,31 +77,11 @@
 
 # Contributed / third party js libs for pipeline compression
 # For hand rolled js for this app, use project.py
-PIPELINE_JS = {
-    'contrib': {
-        'source_filenames': (
-            'js/jquery-1.11.3.js',
-            'js/underscore.1.8.3.js',
-            'js/bootstrap-3.3.5.js'
-        ),
-        'output_filename': 'js/contrib.js',
-    }
-}
+PIPELINE_JS = {}
 
 # Contributed / third party css for pipeline compression
 # For hand rolled css for this app, use project.py
-PIPELINE_CSS = {
-    'contrib': {
-        'source_filenames': (
-            'css/bootstrap.3.3.5.css',
-            'css/bootstrap-theme.3.3.5.css',
-        ),
-        'output_filename': 'css/contrib.css',
-        'extra_context': {
-            'media': 'screen, projection',
-        },
-    }
-}
+PIPELINE_CSS = {}
 
 # These get enabled in prod.py
 PIPELINE_ENABLED = False


Test patch:
Repository: kartoza/prj.app

Issue:
Landing page gives a 404



Discussion:

Resolving patch:
diff --git a/django_project/base/views/error_views.py b/django_project/base/views/error_views.py
--- a/django_project/base/views/error_views.py
+++ b/django_project/base/views/error_views.py
@@ -21,7 +21,11 @@ def custom_404(request, template_name='404.html'):
 
     """
     public_projects = Project.objects.filter(approved=True, private=False)
-    return render_to_response(template_name, {
-        'request_path': request.path,
-        'projects': public_projects
-    }, context_instance=RequestContext(request))
+
+    response = render_to_response(
+        template_name, {
+            'request_path': request.path,
+            'projects': public_projects},
+        context_instance=RequestContext(request))
+    response.status_code = 404
+    return response


Test patch:
Repository: kartoza/prj.app

Issue:
We need to ensure that pending items shows only pending items
At the moment after you edit or create a new site, the pending items list shows all items - it should show only items awaiting moderation.



Discussion:

Resolving patch:
diff --git a/django_project/base/models/project.py b/django_project/base/models/project.py
--- a/django_project/base/models/project.py
+++ b/django_project/base/models/project.py
@@ -19,30 +19,30 @@
 class ApprovedProjectManager(models.Manager):
     """Custom project manager that shows only approved records."""
 
-    def get_query_set(self):
+    def get_queryset(self):
         """Query set generator"""
         return super(
-            ApprovedProjectManager, self).get_query_set().filter(
+            ApprovedProjectManager, self).get_queryset().filter(
                 approved=True)
 
 
 class UnapprovedProjectManager(models.Manager):
     """Custom project manager that shows only unapproved records."""
 
-    def get_query_set(self):
+    def get_queryset(self):
         """Query set generator"""
         return super(
-            UnapprovedProjectManager, self).get_query_set().filter(
+            UnapprovedProjectManager, self).get_queryset().filter(
                 approved=False)
 
 
 class PublicProjectManager(models.Manager):
     """Custom project manager that shows only public and approved projects."""
 
-    def get_query_set(self):
+    def get_queryset(self):
         """Query set generator"""
         return super(
-            PublicProjectManager, self).get_query_set().filter(
+            PublicProjectManager, self).get_queryset().filter(
                 private=False).filter(approved=True)
 
 
diff --git a/django_project/base/views/project.py b/django_project/base/views/project.py
--- a/django_project/base/views/project.py
+++ b/django_project/base/views/project.py
@@ -199,7 +199,7 @@ def get_context_data(self, **kwargs):
 class ApproveProjectView(StaffuserRequiredMixin, ProjectMixin, RedirectView):
     permanent = False
     query_string = True
-    pattern_name = 'pending-project-list'
+    pattern_name = 'home'
 
     def get_redirect_url(self, slug):
         projects_qs = Project.unapproved_objects.all()


Test patch:
Repository: kartoza/prj.app

Issue:
Atom feed gets a 500 error
See http://sentry.kartoza.com/kartoza/projecta-live/group/5846/

Problem is cause by models/entry.py get_absolute_url() method which still uses old slug system to resolve path to an entry.



Discussion:

Resolving patch:
diff --git a/django_project/changes/models/entry.py b/django_project/changes/models/entry.py
--- a/django_project/changes/models/entry.py
+++ b/django_project/changes/models/entry.py
@@ -129,9 +129,7 @@ def __unicode__(self):
 
     def get_absolute_url(self):
         return reverse('entry-detail', kwargs={
-            'slug': self.slug,
-            'version_slug': self.version.slug,
-            'project_slug': self.version.project.slug
+            'pk': self.id
         })
 
     def funder_info_html(self):


Test patch:
Repository: kartoza/prj.app

Issue:
500 error on looking at version view
When using this view: 

http://changelog.linfiniti.com/en/qgis/version/2.14.0/ 

See http://sentry.kartoza.com/kartoza/projecta-live/group/5095/

```
changes/views/version.py ? in get_object (application)

 126.                   obj = queryset.filter(project=project).get(slug=slug)
Copy as cURLReplay this request
```



Discussion:

Resolving patch:
diff --git a/django_project/changes/views/version.py b/django_project/changes/views/version.py
--- a/django_project/changes/views/version.py
+++ b/django_project/changes/views/version.py
@@ -125,7 +125,7 @@ def get_object(self, queryset=None):
                     project = Project.objects.get(slug=project_slug)
                     obj = queryset.filter(project=project).get(slug=slug)
                     return obj
-                except Project.DoesNotExist:
+                except Version.DoesNotExist:
                     Http404(
                         'Sorry! The version you are requesting could not '
                         'be found or you do not have permission to view '


Test patch:
Repository: kartoza/prj.app

Issue:
500 error viewing a version when not logged in
see http://sentry.kartoza.com/kartoza/projecta-live/group/5106/

```
Stacktrace (most recent call first):

  File "django/core/urlresolvers.py", line 495, in _reverse_with_prefix
    (lookup_view_s, args, kwargs, len(patterns), patterns))
  File "django/core/urlresolvers.py", line 578, in reverse
    return force_text(iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs)))
  File "django/template/defaulttags.py", line 493, in render
    url = reverse(view_name, args=args, kwargs=kwargs, current_app=current_app)
  File "django/template/defaulttags.py", line 507, in render
    six.reraise(*exc_info)
  File "django/template/base.py", line 919, in render_node
    return node.render(context)
  File "django/template/base.py", line 905, in render
    bit = self.render_node(node, context)
  File "django/template/loader_tags.py", line 65, in render
    result = block.nodelist.render(context)
  File "django/template/base.py", line 919, in render_node
    return node.render(context)
  File "django/template/base.py", line 905, in render
    bit = self.render_node(node, context)
  File "django/template/base.py", line 202, in _render
    return self.nodelist.render(context)
  File "django/template/loader_tags.py", line 135, in render
    return compiled_parent._render(context)
  File "django/template/base.py", line 919, in render_node
    return node.render(context)
  File "django/template/base.py", line 905, in render
    bit = self.render_node(node, context)
  File "django/template/base.py", line 202, in _render
    return self.nodelist.render(context)
  File "django/template/base.py", line 210, in render
    return self._render(context)
  File "django/template/backends/django.py", line 74, in render
    return self.template.render(context)
  File "django/template/response.py", line 135, in rendered_content
    content = template.render(context, self._request)
  File "django/template/response.py", line 158, in render
    self.content = self.rendered_content
  File "django/core/handlers/base.py", line 164, in get_response
    response = response.render()
```



Discussion:

Resolving patch:
diff --git a/django_project/changes/views/version.py b/django_project/changes/views/version.py
--- a/django_project/changes/views/version.py
+++ b/django_project/changes/views/version.py
@@ -126,10 +126,12 @@ def get_object(self, queryset=None):
                     obj = queryset.filter(project=project).get(slug=slug)
                     return obj
                 except Version.DoesNotExist:
-                    Http404(
+                    raise Http404(
                         'Sorry! The version you are requesting could not '
                         'be found or you do not have permission to view '
-                        'the version. Try logging in?')
+                        'the version. Also the version may not be approved '
+                        'yet. Try logging in as a staff member if you wish '
+                        'to view it.')
             else:
                 raise Http404('Sorry! We could not find your version!')
 


Test patch:
Repository: kartoza/prj.app

Issue:
Developed by, created by etc should be shown in changelog entries read only view



Discussion:

Resolving patch:
diff --git a/django_project/changes/views/category.py b/django_project/changes/views/category.py
--- a/django_project/changes/views/category.py
+++ b/django_project/changes/views/category.py
@@ -216,9 +216,18 @@ def get_object(self, queryset=None):
         slug = self.kwargs.get('slug', None)
         project_slug = self.kwargs.get('project_slug', None)
         if slug and project_slug:
-            project = Project.objects.get(slug=project_slug)
-            obj = queryset.get(project=project, slug=slug)
-            return obj
+            try:
+                project = Project.objects.get(slug=project_slug)
+            except Project.DoesNotExist:
+                raise Http404(
+                    'The project you requested a category for does not exist.'
+                )
+            try:
+                obj = queryset.get(project=project, slug=slug)
+                return obj
+            except Category.DoesNotExist:
+                raise Http404(
+                    'The category you requested does not exist.')
         else:
             raise Http404('Sorry! We could not find your category!')
 


Test patch:
Repository: kartoza/prj.app

Issue:
Disqus functionality is currently broken
There should be disqus inline chat widgets on each version page and each entry page. Currently these are not working - can we work to fix it.



Discussion:

Resolving patch:
diff --git a/django_project/core/settings/contrib.py b/django_project/core/settings/contrib.py
--- a/django_project/core/settings/contrib.py
+++ b/django_project/core/settings/contrib.py
@@ -20,8 +20,12 @@
     'django_hashedfilenamestorage',
     'django_countries',  # for sponsor addresses
     # 'user_map',
+    'disqus',
 )
 
+# Set disqus and shortname
+# noinspection PyUnresolvedReferences
+from .secret import DISQUS_WEBSITE_SHORTNAME  # noqa
 
 MIGRATION_MODULES = {'accounts': 'core.migration'}
 
diff --git a/django_project/core/settings/project.py b/django_project/core/settings/project.py
--- a/django_project/core/settings/project.py
+++ b/django_project/core/settings/project.py
@@ -17,7 +17,6 @@
     'changes',
     'github_issue',
     'vota',
-    'disqus',
 )
 
 # Due to profile page does not available, this will redirect to home page after login


Test patch: