We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Management command for published resources
**Describe the feature you'd like and what it will do**
We should have a management command to report on resources published within a timeframe.
Consider also adding to our metrics system

**Additional context**
HS 2.9.2


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `hs_core/management/commands/list_published_by_year.py`
Content:
```
1 """Lists all the resources published in a given year.
2 """
3 
4 from django.core.management.base import BaseCommand
5 from django.contrib.auth.models import User
6 from hs_core.models import BaseResource
7 from hs_access_control.models import PrivilegeCodes
8 from hs_core import hydroshare
9 from django.db.models import F
10 from datetime import timedelta
11 from django.utils import timezone
12 from django.core.exceptions import ObjectDoesNotExist
13 
14 
15 class Command(BaseCommand):
16     help = "Print resource information"
17 
18     def add_arguments(self, parser):
19         # Named (optional) arguments
20         parser.add_argument(
21             '--year',
22             dest='year',
23             help='limit to resources published in a given year'
24         )
25 
26         parser.add_argument('--days', type=int, dest='days', help='include resources updated in the last X days')
27 
28         parser.add_argument(
29             '--type',
30             dest='type',
31             help='limit to resources of a particular type'
32         )
33 
34         parser.add_argument(
35             '--owned_by',
36             dest='owned_by',
37             help='limit to resources owned by specific user'
38         )
39 
40     def handle(self, *args, **options):
41         days = options['days']
42         resources = BaseResource.objects.filter(raccess__published=True)
43         owner = options['owned_by']
44         type = options['type']
45 
46         if owner is not None:
47             try:
48                 owner = User.objects.get(username=owner)
49                 resources.filter(r2urp__user=owner,
50                                  r2urp__privilege=PrivilegeCodes.OWNER)
51             except ObjectDoesNotExist:
52                 print(f"User matching {owner} not found")
53 
54         if type is not None:
55             if type in ["CompositeResource", "CollectionResource"]:
56                 resources.filter(resource_type=type)
57             else:
58                 print(f"Type {type} is not supported. Must be 'CompositeResource' or 'CollectionResource'")
59 
60         resources = resources.order_by(F('updated').asc(nulls_first=True))
61 
62         for resource in resources:
63             pub_date = self.get_publication_date(resource)
64             if options['year']:
65                 if pub_date.year != int(options['year']):
66                     continue
67             if days:
68                 cuttoff_time = timezone.now() - timedelta(days)
69                 if not pub_date >= cuttoff_time:
70                     continue
71             self.print_resource(resource, pub_date)
72 
73     def get_publication_date(self, resource):
74         published_date = resource.metadata.dates.filter(type="published").first()
75         if not published_date:
76             print(f"Publication date not found for {resource.short_id}")
77         return published_date
78 
79     def print_resource(self, res, pub_date):
80         site_url = hydroshare.utils.current_site_url()
81         res_url = site_url + res.absolute_url
82         funding_agencies = res.metadata.funding_agencies.all()
83         print("*" * 100)
84         print(f"{res_url}")
85         print(res.metadata.title.value)
86         print(f"Resource type: {res.resource_type}")
87         if pub_date:
88             print(f"Published on {pub_date}")
89         else:
90             print("Resource has no publication date")
91 
92         if funding_agencies:
93             print("Funding agency/agencies:")
94             for f in funding_agencies:
95                 print(f.agency_name)
96         else:
97             print("Resource has no funding agency")
98 
99         if res.doi:
100             print(res.doi)
101         else:
102             print("Resource has no doi")
103
```
--- 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/hs_core/management/commands/list_published_by_year.py b/hs_core/management/commands/list_published_by_year.py
--- a/hs_core/management/commands/list_published_by_year.py
+++ b/hs_core/management/commands/list_published_by_year.py
@@ -41,7 +41,7 @@
         days = options['days']
         resources = BaseResource.objects.filter(raccess__published=True)
         owner = options['owned_by']
-        type = options['type']
+        res_type = options['type']
 
         if owner is not None:
             try:
@@ -51,11 +51,11 @@
             except ObjectDoesNotExist:
                 print(f"User matching {owner} not found")
 
-        if type is not None:
-            if type in ["CompositeResource", "CollectionResource"]:
-                resources.filter(resource_type=type)
+        if res_type is not None:
+            if res_type in ["CompositeResource", "CollectionResource"]:
+                resources.filter(resource_type=res_type)
             else:
-                print(f"Type {type} is not supported. Must be 'CompositeResource' or 'CollectionResource'")
+                print(f"Type {res_type} is not supported. Must be 'CompositeResource' or 'CollectionResource'")
 
         resources = resources.order_by(F('updated').asc(nulls_first=True))
 
@@ -74,14 +74,19 @@
         published_date = resource.metadata.dates.filter(type="published").first()
         if not published_date:
             print(f"Publication date not found for {resource.short_id}")
-        return published_date
+        return published_date.start_date
 
     def print_resource(self, res, pub_date):
         site_url = hydroshare.utils.current_site_url()
         res_url = site_url + res.absolute_url
         funding_agencies = res.metadata.funding_agencies.all()
+        print("\n")
         print("*" * 100)
         print(f"{res_url}")
+        if res.doi:
+            print(res.doi)
+        else:
+            print("Resource has no doi")
         print(res.metadata.title.value)
         print(f"Resource type: {res.resource_type}")
         if pub_date:
@@ -90,13 +95,24 @@
             print("Resource has no publication date")
 
         if funding_agencies:
-            print("Funding agency/agencies:")
-            for f in funding_agencies:
-                print(f.agency_name)
+            print(f"Found {len(funding_agencies)} funder(s):")
+            for count, f in enumerate(funding_agencies, 1):
+                print(f"--- Funder #{count} ---")
+                if f.agency_name:
+                    print(f"Agency name: {f.agency_name}")
+                else:
+                    print("No agency name")
+                if f.agency_url:
+                    print(f"Agency url: {f.agency_url}")
+                else:
+                    print("No agency url")
+                if f.award_title:
+                    print(f"Award title: {f.award_title}")
+                else:
+                    print("No award title")
+                if f.award_number:
+                    print(f"Award number: {f.award_number}")
+                else:
+                    print("No award number")
         else:
-            print("Resource has no funding agency")
-
-        if res.doi:
-            print(res.doi)
-        else:
-            print("Resource has no doi")
+            print("Resource has no funding information")

{"golden_diff": "diff --git a/hs_core/management/commands/list_published_by_year.py b/hs_core/management/commands/list_published_by_year.py\n--- a/hs_core/management/commands/list_published_by_year.py\n+++ b/hs_core/management/commands/list_published_by_year.py\n@@ -41,7 +41,7 @@\n         days = options['days']\n         resources = BaseResource.objects.filter(raccess__published=True)\n         owner = options['owned_by']\n-        type = options['type']\n+        res_type = options['type']\n \n         if owner is not None:\n             try:\n@@ -51,11 +51,11 @@\n             except ObjectDoesNotExist:\n                 print(f\"User matching {owner} not found\")\n \n-        if type is not None:\n-            if type in [\"CompositeResource\", \"CollectionResource\"]:\n-                resources.filter(resource_type=type)\n+        if res_type is not None:\n+            if res_type in [\"CompositeResource\", \"CollectionResource\"]:\n+                resources.filter(resource_type=res_type)\n             else:\n-                print(f\"Type {type} is not supported. Must be 'CompositeResource' or 'CollectionResource'\")\n+                print(f\"Type {res_type} is not supported. Must be 'CompositeResource' or 'CollectionResource'\")\n \n         resources = resources.order_by(F('updated').asc(nulls_first=True))\n \n@@ -74,14 +74,19 @@\n         published_date = resource.metadata.dates.filter(type=\"published\").first()\n         if not published_date:\n             print(f\"Publication date not found for {resource.short_id}\")\n-        return published_date\n+        return published_date.start_date\n \n     def print_resource(self, res, pub_date):\n         site_url = hydroshare.utils.current_site_url()\n         res_url = site_url + res.absolute_url\n         funding_agencies = res.metadata.funding_agencies.all()\n+        print(\"\\n\")\n         print(\"*\" * 100)\n         print(f\"{res_url}\")\n+        if res.doi:\n+            print(res.doi)\n+        else:\n+            print(\"Resource has no doi\")\n         print(res.metadata.title.value)\n         print(f\"Resource type: {res.resource_type}\")\n         if pub_date:\n@@ -90,13 +95,24 @@\n             print(\"Resource has no publication date\")\n \n         if funding_agencies:\n-            print(\"Funding agency/agencies:\")\n-            for f in funding_agencies:\n-                print(f.agency_name)\n+            print(f\"Found {len(funding_agencies)} funder(s):\")\n+            for count, f in enumerate(funding_agencies, 1):\n+                print(f\"--- Funder #{count} ---\")\n+                if f.agency_name:\n+                    print(f\"Agency name: {f.agency_name}\")\n+                else:\n+                    print(\"No agency name\")\n+                if f.agency_url:\n+                    print(f\"Agency url: {f.agency_url}\")\n+                else:\n+                    print(\"No agency url\")\n+                if f.award_title:\n+                    print(f\"Award title: {f.award_title}\")\n+                else:\n+                    print(\"No award title\")\n+                if f.award_number:\n+                    print(f\"Award number: {f.award_number}\")\n+                else:\n+                    print(\"No award number\")\n         else:\n-            print(\"Resource has no funding agency\")\n-\n-        if res.doi:\n-            print(res.doi)\n-        else:\n-            print(\"Resource has no doi\")\n+            print(\"Resource has no funding information\")\n", "issue": "Management command for published resources\n**Describe the feature you'd like and what it will do**\r\nWe should have a management command to report on resources published within a timeframe.\r\nConsider also adding to our metrics system\r\n\r\n**Additional context**\r\nHS 2.9.2\r\n\n", "before_files": [{"content": "\"\"\"Lists all the resources published in a given year.\n\"\"\"\n\nfrom django.core.management.base import BaseCommand\nfrom django.contrib.auth.models import User\nfrom hs_core.models import BaseResource\nfrom hs_access_control.models import PrivilegeCodes\nfrom hs_core import hydroshare\nfrom django.db.models import F\nfrom datetime import timedelta\nfrom django.utils import timezone\nfrom django.core.exceptions import ObjectDoesNotExist\n\n\nclass Command(BaseCommand):\n    help = \"Print resource information\"\n\n    def add_arguments(self, parser):\n        # Named (optional) arguments\n        parser.add_argument(\n            '--year',\n            dest='year',\n            help='limit to resources published in a given year'\n        )\n\n        parser.add_argument('--days', type=int, dest='days', help='include resources updated in the last X days')\n\n        parser.add_argument(\n            '--type',\n            dest='type',\n            help='limit to resources of a particular type'\n        )\n\n        parser.add_argument(\n            '--owned_by',\n            dest='owned_by',\n            help='limit to resources owned by specific user'\n        )\n\n    def handle(self, *args, **options):\n        days = options['days']\n        resources = BaseResource.objects.filter(raccess__published=True)\n        owner = options['owned_by']\n        type = options['type']\n\n        if owner is not None:\n            try:\n                owner = User.objects.get(username=owner)\n                resources.filter(r2urp__user=owner,\n                                 r2urp__privilege=PrivilegeCodes.OWNER)\n            except ObjectDoesNotExist:\n                print(f\"User matching {owner} not found\")\n\n        if type is not None:\n            if type in [\"CompositeResource\", \"CollectionResource\"]:\n                resources.filter(resource_type=type)\n            else:\n                print(f\"Type {type} is not supported. Must be 'CompositeResource' or 'CollectionResource'\")\n\n        resources = resources.order_by(F('updated').asc(nulls_first=True))\n\n        for resource in resources:\n            pub_date = self.get_publication_date(resource)\n            if options['year']:\n                if pub_date.year != int(options['year']):\n                    continue\n            if days:\n                cuttoff_time = timezone.now() - timedelta(days)\n                if not pub_date >= cuttoff_time:\n                    continue\n            self.print_resource(resource, pub_date)\n\n    def get_publication_date(self, resource):\n        published_date = resource.metadata.dates.filter(type=\"published\").first()\n        if not published_date:\n            print(f\"Publication date not found for {resource.short_id}\")\n        return published_date\n\n    def print_resource(self, res, pub_date):\n        site_url = hydroshare.utils.current_site_url()\n        res_url = site_url + res.absolute_url\n        funding_agencies = res.metadata.funding_agencies.all()\n        print(\"*\" * 100)\n        print(f\"{res_url}\")\n        print(res.metadata.title.value)\n        print(f\"Resource type: {res.resource_type}\")\n        if pub_date:\n            print(f\"Published on {pub_date}\")\n        else:\n            print(\"Resource has no publication date\")\n\n        if funding_agencies:\n            print(\"Funding agency/agencies:\")\n            for f in funding_agencies:\n                print(f.agency_name)\n        else:\n            print(\"Resource has no funding agency\")\n\n        if res.doi:\n            print(res.doi)\n        else:\n            print(\"Resource has no doi\")\n", "path": "hs_core/management/commands/list_published_by_year.py"}], "after_files": [{"content": "\"\"\"Lists all the resources published in a given year.\n\"\"\"\n\nfrom django.core.management.base import BaseCommand\nfrom django.contrib.auth.models import User\nfrom hs_core.models import BaseResource\nfrom hs_access_control.models import PrivilegeCodes\nfrom hs_core import hydroshare\nfrom django.db.models import F\nfrom datetime import timedelta\nfrom django.utils import timezone\nfrom django.core.exceptions import ObjectDoesNotExist\n\n\nclass Command(BaseCommand):\n    help = \"Print resource information\"\n\n    def add_arguments(self, parser):\n        # Named (optional) arguments\n        parser.add_argument(\n            '--year',\n            dest='year',\n            help='limit to resources published in a given year'\n        )\n\n        parser.add_argument('--days', type=int, dest='days', help='include resources updated in the last X days')\n\n        parser.add_argument(\n            '--type',\n            dest='type',\n            help='limit to resources of a particular type'\n        )\n\n        parser.add_argument(\n            '--owned_by',\n            dest='owned_by',\n            help='limit to resources owned by specific user'\n        )\n\n    def handle(self, *args, **options):\n        days = options['days']\n        resources = BaseResource.objects.filter(raccess__published=True)\n        owner = options['owned_by']\n        res_type = options['type']\n\n        if owner is not None:\n            try:\n                owner = User.objects.get(username=owner)\n                resources.filter(r2urp__user=owner,\n                                 r2urp__privilege=PrivilegeCodes.OWNER)\n            except ObjectDoesNotExist:\n                print(f\"User matching {owner} not found\")\n\n        if res_type is not None:\n            if res_type in [\"CompositeResource\", \"CollectionResource\"]:\n                resources.filter(resource_type=res_type)\n            else:\n                print(f\"Type {res_type} is not supported. Must be 'CompositeResource' or 'CollectionResource'\")\n\n        resources = resources.order_by(F('updated').asc(nulls_first=True))\n\n        for resource in resources:\n            pub_date = self.get_publication_date(resource)\n            if options['year']:\n                if pub_date.year != int(options['year']):\n                    continue\n            if days:\n                cuttoff_time = timezone.now() - timedelta(days)\n                if not pub_date >= cuttoff_time:\n                    continue\n            self.print_resource(resource, pub_date)\n\n    def get_publication_date(self, resource):\n        published_date = resource.metadata.dates.filter(type=\"published\").first()\n        if not published_date:\n            print(f\"Publication date not found for {resource.short_id}\")\n        return published_date.start_date\n\n    def print_resource(self, res, pub_date):\n        site_url = hydroshare.utils.current_site_url()\n        res_url = site_url + res.absolute_url\n        funding_agencies = res.metadata.funding_agencies.all()\n        print(\"\\n\")\n        print(\"*\" * 100)\n        print(f\"{res_url}\")\n        if res.doi:\n            print(res.doi)\n        else:\n            print(\"Resource has no doi\")\n        print(res.metadata.title.value)\n        print(f\"Resource type: {res.resource_type}\")\n        if pub_date:\n            print(f\"Published on {pub_date}\")\n        else:\n            print(\"Resource has no publication date\")\n\n        if funding_agencies:\n            print(f\"Found {len(funding_agencies)} funder(s):\")\n            for count, f in enumerate(funding_agencies, 1):\n                print(f\"--- Funder #{count} ---\")\n                if f.agency_name:\n                    print(f\"Agency name: {f.agency_name}\")\n                else:\n                    print(\"No agency name\")\n                if f.agency_url:\n                    print(f\"Agency url: {f.agency_url}\")\n                else:\n                    print(\"No agency url\")\n                if f.award_title:\n                    print(f\"Award title: {f.award_title}\")\n                else:\n                    print(\"No award title\")\n                if f.award_number:\n                    print(f\"Award number: {f.award_number}\")\n                else:\n                    print(\"No award number\")\n        else:\n            print(\"Resource has no funding information\")\n", "path": "hs_core/management/commands/list_published_by_year.py"}]}