We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Show only relevant updates in typeahead on Akvo pages
Currently, all updates can be searched for on partner site updates typeahead. 

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `akvo/rest/views/typeahead.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 
3 """Akvo RSR is covered by the GNU Affero General Public License.
4 See more details in the license.txt file located at the root folder of the
5 Akvo RSR module. For additional details on the GNU license please
6 see < http://www.gnu.org/licenses/agpl.html >.
7 """
8 
9 from django.conf import settings
10 from rest_framework.decorators import api_view
11 from rest_framework.response import Response
12 
13 from akvo.codelists.models import Country, Version
14 from akvo.rest.serializers import (TypeaheadCountrySerializer,
15                                    TypeaheadOrganisationSerializer,
16                                    TypeaheadProjectSerializer,
17                                    TypeaheadProjectUpdateSerializer,
18                                    TypeaheadKeywordSerializer,)
19 from akvo.rsr.models import Organisation, Project, ProjectUpdate
20 from akvo.rsr.views.project import _project_directory_coll
21 
22 
23 def rejig(queryset, serializer):
24     """Rearrange & add queryset count to the response data."""
25     return {
26         'count': queryset.count(),
27         'results': serializer.data
28     }
29 
30 
31 @api_view(['GET'])
32 def typeahead_country(request):
33     iati_version = Version.objects.get(code=settings.IATI_VERSION)
34     countries = Country.objects.filter(version=iati_version)
35     return Response(
36         rejig(countries, TypeaheadCountrySerializer(countries, many=True))
37     )
38 
39 
40 @api_view(['GET'])
41 def typeahead_organisation(request):
42     page = request.rsr_page
43     if request.GET.get('partners', '0') == '1' and page:
44         organisations = page.partners()
45     else:
46         # Project editor - all organizations
47         organisations = Organisation.objects.all()
48 
49     organisations = organisations.values('id', 'name', 'long_name')
50 
51     return Response(
52         rejig(organisations, TypeaheadOrganisationSerializer(organisations,
53                                                              many=True))
54     )
55 
56 
57 @api_view(['GET'])
58 def typeahead_user_organisations(request):
59     user = request.user
60     is_admin = user.is_active and (user.is_superuser or user.is_admin)
61     organisations = user.approved_organisations() if not is_admin else Organisation.objects.all()
62     return Response(
63         rejig(organisations, TypeaheadOrganisationSerializer(organisations,
64                                                              many=True))
65     )
66 
67 
68 @api_view(['GET'])
69 def typeahead_keyword(request):
70     page = request.rsr_page
71     keywords = page.keywords.all() if page else None
72     if keywords:
73         return Response(
74             rejig(keywords, TypeaheadKeywordSerializer(keywords, many=True))
75         )
76     # No keywords on rsr.akvo.org
77     return Response({})
78 
79 
80 @api_view(['GET'])
81 def typeahead_project(request):
82     """Return the typeaheads for projects.
83 
84     Without any query parameters, it returns the info for all the projects in
85     the current context -- changes depending on whether we are on a partner
86     site, or the RSR site.
87 
88     If a published query parameter is passed, only projects that have been
89     published are returned.
90 
91     NOTE: The unauthenticated user gets information about all the projects when
92     using this API endpoint.  More permission checking will need to be added,
93     if the amount of data being returned is changed.
94 
95     """
96     if request.GET.get('published', '0') == '0':
97         # Project editor - organization projects, all
98         page = request.rsr_page
99         projects = page.all_projects() if page else Project.objects.all()
100     else:
101         # Search bar - organization projects, published
102         projects = _project_directory_coll(request)
103 
104     projects = projects.exclude(title='')
105     return Response(
106         rejig(projects, TypeaheadProjectSerializer(projects, many=True))
107     )
108 
109 
110 @api_view(['GET'])
111 def typeahead_user_projects(request):
112     user = request.user
113     is_admin = user.is_active and (user.is_superuser or user.is_admin)
114     if is_admin:
115         projects = Project.objects.all()
116     else:
117         projects = user.approved_organisations().all_projects()
118     projects = projects.exclude(title='')
119     return Response(
120         rejig(projects, TypeaheadProjectSerializer(projects, many=True))
121     )
122 
123 
124 @api_view(['GET'])
125 def typeahead_impact_projects(request):
126     user = request.user
127     projects = Project.objects.all() if user.is_admin or user.is_superuser else user.my_projects()
128     projects = projects.published().filter(is_impact_project=True).order_by('title')
129 
130     return Response(
131         rejig(projects, TypeaheadProjectSerializer(projects, many=True))
132     )
133 
134 
135 @api_view(['GET'])
136 def typeahead_projectupdate(request):
137     updates = ProjectUpdate.objects.all()
138     return Response(
139         rejig(updates, TypeaheadProjectUpdateSerializer(updates, many=True))
140     )
141
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/akvo/rest/views/typeahead.py b/akvo/rest/views/typeahead.py
--- a/akvo/rest/views/typeahead.py
+++ b/akvo/rest/views/typeahead.py
@@ -134,7 +134,8 @@
 
 @api_view(['GET'])
 def typeahead_projectupdate(request):
-    updates = ProjectUpdate.objects.all()
+    page = request.rsr_page
+    updates = page.updates() if page else ProjectUpdate.objects.all()
     return Response(
         rejig(updates, TypeaheadProjectUpdateSerializer(updates, many=True))
     )

{"golden_diff": "diff --git a/akvo/rest/views/typeahead.py b/akvo/rest/views/typeahead.py\n--- a/akvo/rest/views/typeahead.py\n+++ b/akvo/rest/views/typeahead.py\n@@ -134,7 +134,8 @@\n \n @api_view(['GET'])\n def typeahead_projectupdate(request):\n-    updates = ProjectUpdate.objects.all()\n+    page = request.rsr_page\n+    updates = page.updates() if page else ProjectUpdate.objects.all()\n     return Response(\n         rejig(updates, TypeaheadProjectUpdateSerializer(updates, many=True))\n     )\n", "issue": "Show only relevant updates in typeahead on Akvo pages\nCurrently, all updates can be searched for on partner site updates typeahead. \n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\n\"\"\"Akvo RSR is covered by the GNU Affero General Public License.\nSee more details in the license.txt file located at the root folder of the\nAkvo RSR module. For additional details on the GNU license please\nsee < http://www.gnu.org/licenses/agpl.html >.\n\"\"\"\n\nfrom django.conf import settings\nfrom rest_framework.decorators import api_view\nfrom rest_framework.response import Response\n\nfrom akvo.codelists.models import Country, Version\nfrom akvo.rest.serializers import (TypeaheadCountrySerializer,\n                                   TypeaheadOrganisationSerializer,\n                                   TypeaheadProjectSerializer,\n                                   TypeaheadProjectUpdateSerializer,\n                                   TypeaheadKeywordSerializer,)\nfrom akvo.rsr.models import Organisation, Project, ProjectUpdate\nfrom akvo.rsr.views.project import _project_directory_coll\n\n\ndef rejig(queryset, serializer):\n    \"\"\"Rearrange & add queryset count to the response data.\"\"\"\n    return {\n        'count': queryset.count(),\n        'results': serializer.data\n    }\n\n\n@api_view(['GET'])\ndef typeahead_country(request):\n    iati_version = Version.objects.get(code=settings.IATI_VERSION)\n    countries = Country.objects.filter(version=iati_version)\n    return Response(\n        rejig(countries, TypeaheadCountrySerializer(countries, many=True))\n    )\n\n\n@api_view(['GET'])\ndef typeahead_organisation(request):\n    page = request.rsr_page\n    if request.GET.get('partners', '0') == '1' and page:\n        organisations = page.partners()\n    else:\n        # Project editor - all organizations\n        organisations = Organisation.objects.all()\n\n    organisations = organisations.values('id', 'name', 'long_name')\n\n    return Response(\n        rejig(organisations, TypeaheadOrganisationSerializer(organisations,\n                                                             many=True))\n    )\n\n\n@api_view(['GET'])\ndef typeahead_user_organisations(request):\n    user = request.user\n    is_admin = user.is_active and (user.is_superuser or user.is_admin)\n    organisations = user.approved_organisations() if not is_admin else Organisation.objects.all()\n    return Response(\n        rejig(organisations, TypeaheadOrganisationSerializer(organisations,\n                                                             many=True))\n    )\n\n\n@api_view(['GET'])\ndef typeahead_keyword(request):\n    page = request.rsr_page\n    keywords = page.keywords.all() if page else None\n    if keywords:\n        return Response(\n            rejig(keywords, TypeaheadKeywordSerializer(keywords, many=True))\n        )\n    # No keywords on rsr.akvo.org\n    return Response({})\n\n\n@api_view(['GET'])\ndef typeahead_project(request):\n    \"\"\"Return the typeaheads for projects.\n\n    Without any query parameters, it returns the info for all the projects in\n    the current context -- changes depending on whether we are on a partner\n    site, or the RSR site.\n\n    If a published query parameter is passed, only projects that have been\n    published are returned.\n\n    NOTE: The unauthenticated user gets information about all the projects when\n    using this API endpoint.  More permission checking will need to be added,\n    if the amount of data being returned is changed.\n\n    \"\"\"\n    if request.GET.get('published', '0') == '0':\n        # Project editor - organization projects, all\n        page = request.rsr_page\n        projects = page.all_projects() if page else Project.objects.all()\n    else:\n        # Search bar - organization projects, published\n        projects = _project_directory_coll(request)\n\n    projects = projects.exclude(title='')\n    return Response(\n        rejig(projects, TypeaheadProjectSerializer(projects, many=True))\n    )\n\n\n@api_view(['GET'])\ndef typeahead_user_projects(request):\n    user = request.user\n    is_admin = user.is_active and (user.is_superuser or user.is_admin)\n    if is_admin:\n        projects = Project.objects.all()\n    else:\n        projects = user.approved_organisations().all_projects()\n    projects = projects.exclude(title='')\n    return Response(\n        rejig(projects, TypeaheadProjectSerializer(projects, many=True))\n    )\n\n\n@api_view(['GET'])\ndef typeahead_impact_projects(request):\n    user = request.user\n    projects = Project.objects.all() if user.is_admin or user.is_superuser else user.my_projects()\n    projects = projects.published().filter(is_impact_project=True).order_by('title')\n\n    return Response(\n        rejig(projects, TypeaheadProjectSerializer(projects, many=True))\n    )\n\n\n@api_view(['GET'])\ndef typeahead_projectupdate(request):\n    updates = ProjectUpdate.objects.all()\n    return Response(\n        rejig(updates, TypeaheadProjectUpdateSerializer(updates, many=True))\n    )\n", "path": "akvo/rest/views/typeahead.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n\n\"\"\"Akvo RSR is covered by the GNU Affero General Public License.\nSee more details in the license.txt file located at the root folder of the\nAkvo RSR module. For additional details on the GNU license please\nsee < http://www.gnu.org/licenses/agpl.html >.\n\"\"\"\n\nfrom django.conf import settings\nfrom rest_framework.decorators import api_view\nfrom rest_framework.response import Response\n\nfrom akvo.codelists.models import Country, Version\nfrom akvo.rest.serializers import (TypeaheadCountrySerializer,\n                                   TypeaheadOrganisationSerializer,\n                                   TypeaheadProjectSerializer,\n                                   TypeaheadProjectUpdateSerializer,\n                                   TypeaheadKeywordSerializer,)\nfrom akvo.rsr.models import Organisation, Project, ProjectUpdate\nfrom akvo.rsr.views.project import _project_directory_coll\n\n\ndef rejig(queryset, serializer):\n    \"\"\"Rearrange & add queryset count to the response data.\"\"\"\n    return {\n        'count': queryset.count(),\n        'results': serializer.data\n    }\n\n\n@api_view(['GET'])\ndef typeahead_country(request):\n    iati_version = Version.objects.get(code=settings.IATI_VERSION)\n    countries = Country.objects.filter(version=iati_version)\n    return Response(\n        rejig(countries, TypeaheadCountrySerializer(countries, many=True))\n    )\n\n\n@api_view(['GET'])\ndef typeahead_organisation(request):\n    page = request.rsr_page\n    if request.GET.get('partners', '0') == '1' and page:\n        organisations = page.partners()\n    else:\n        # Project editor - all organizations\n        organisations = Organisation.objects.all()\n\n    organisations = organisations.values('id', 'name', 'long_name')\n\n    return Response(\n        rejig(organisations, TypeaheadOrganisationSerializer(organisations,\n                                                             many=True))\n    )\n\n\n@api_view(['GET'])\ndef typeahead_user_organisations(request):\n    user = request.user\n    is_admin = user.is_active and (user.is_superuser or user.is_admin)\n    organisations = user.approved_organisations() if not is_admin else Organisation.objects.all()\n    return Response(\n        rejig(organisations, TypeaheadOrganisationSerializer(organisations,\n                                                             many=True))\n    )\n\n\n@api_view(['GET'])\ndef typeahead_keyword(request):\n    page = request.rsr_page\n    keywords = page.keywords.all() if page else None\n    if keywords:\n        return Response(\n            rejig(keywords, TypeaheadKeywordSerializer(keywords, many=True))\n        )\n    # No keywords on rsr.akvo.org\n    return Response({})\n\n\n@api_view(['GET'])\ndef typeahead_project(request):\n    \"\"\"Return the typeaheads for projects.\n\n    Without any query parameters, it returns the info for all the projects in\n    the current context -- changes depending on whether we are on a partner\n    site, or the RSR site.\n\n    If a published query parameter is passed, only projects that have been\n    published are returned.\n\n    NOTE: The unauthenticated user gets information about all the projects when\n    using this API endpoint.  More permission checking will need to be added,\n    if the amount of data being returned is changed.\n\n    \"\"\"\n    if request.GET.get('published', '0') == '0':\n        # Project editor - organization projects, all\n        page = request.rsr_page\n        projects = page.all_projects() if page else Project.objects.all()\n    else:\n        # Search bar - organization projects, published\n        projects = _project_directory_coll(request)\n\n    projects = projects.exclude(title='')\n    return Response(\n        rejig(projects, TypeaheadProjectSerializer(projects, many=True))\n    )\n\n\n@api_view(['GET'])\ndef typeahead_user_projects(request):\n    user = request.user\n    is_admin = user.is_active and (user.is_superuser or user.is_admin)\n    if is_admin:\n        projects = Project.objects.all()\n    else:\n        projects = user.approved_organisations().all_projects()\n    projects = projects.exclude(title='')\n    return Response(\n        rejig(projects, TypeaheadProjectSerializer(projects, many=True))\n    )\n\n\n@api_view(['GET'])\ndef typeahead_impact_projects(request):\n    user = request.user\n    projects = Project.objects.all() if user.is_admin or user.is_superuser else user.my_projects()\n    projects = projects.published().filter(is_impact_project=True).order_by('title')\n\n    return Response(\n        rejig(projects, TypeaheadProjectSerializer(projects, many=True))\n    )\n\n\n@api_view(['GET'])\ndef typeahead_projectupdate(request):\n    page = request.rsr_page\n    updates = page.updates() if page else ProjectUpdate.objects.all()\n    return Response(\n        rejig(updates, TypeaheadProjectUpdateSerializer(updates, many=True))\n    )\n", "path": "akvo/rest/views/typeahead.py"}]}