prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Allow passing date range for perform_iati_checks
  Currently, [`perform_iati_checks`](https://github.com/akvo/akvo-rsr/blob/master/akvo/rsr/management/commands/perform_iati_checks.py) only has the `--all` option. It should be possible to pass a date range of projects to execute the script on.
  
  Executing it on all projects is unnecessary as most are probably inactive.
  
  This is related to #4779 as some project will have to be rechecked and we don't want to check all projects.
  
  </issue>
  <code>
  [start of akvo/rsr/management/commands/perform_iati_checks.py]
  1 # -*- coding: utf-8 -*-
  2 
  3 # Akvo Reporting 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 Akvo RSR module.
  5 # For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.
  6 
  7 from akvo.rsr.models.project import Project
  8 
  9 from django.core.management.base import BaseCommand
  10 
  11 
  12 class Command(BaseCommand):
  13     help = "Perform all IATI checks for projects."
  14 
  15     def add_arguments(self, parser):
  16         parser.add_argument(
  17             '--all',
  18             action='store_true',
  19             default=False,
  20             help='Run IATI checks for all the projects in the DB.',
  21         )
  22 
  23     def handle(self, *args, **options):
  24         projects = Project.objects.all() if options['all'] else Project.objects.filter(run_iati_checks=True)
  25         self.stdout.write('Performing IATI checks for {} ...'.format(projects.count()))
  26         for project in projects:
  27             self.stdout.write('Performing IATI checks for project {0}...'.format(project.pk))
  28             project.update_iati_checks()
  29
  [end of akvo/rsr/management/commands/perform_iati_checks.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/akvo/rsr/management/commands/perform_iati_checks.py b/akvo/rsr/management/commands/perform_iati_checks.py
  --- a/akvo/rsr/management/commands/perform_iati_checks.py
  +++ b/akvo/rsr/management/commands/perform_iati_checks.py
  @@ -3,25 +3,60 @@
   # Akvo Reporting is covered by the GNU Affero General Public License.
   # See more details in the license.txt file located at the root folder of the Akvo RSR module.
   # For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.
  +import argparse
  +import datetime
   
   from akvo.rsr.models.project import Project
   
   from django.core.management.base import BaseCommand
   
   
  +def date_arg_type(string):
  +    return datetime.datetime.strptime(string, '%Y-%m-%d').date()
  +
  +
   class Command(BaseCommand):
       help = "Perform all IATI checks for projects."
   
  -    def add_arguments(self, parser):
  +    def add_arguments(self, parser: argparse.ArgumentParser):
           parser.add_argument(
               '--all',
               action='store_true',
               default=False,
               help='Run IATI checks for all the projects in the DB.',
  +
  +        )
  +        parser.add_argument(
  +            '--date-start',
  +            type=date_arg_type,
  +            help='Limit to projects created on and after this day',
  +        )
  +        parser.add_argument(
  +            '--date-end',
  +            type=date_arg_type,
  +            help='Limit to projects created on or before this day',
           )
   
       def handle(self, *args, **options):
  -        projects = Project.objects.all() if options['all'] else Project.objects.filter(run_iati_checks=True)
  +        all_option = options["all"]
  +        date_start = options["date_start"]
  +        date_end = options["date_end"]
  +
  +        # Filter projects with options
  +        projects = Project.objects.all()
  +        if not (all_option or date_start or date_end):
  +            self.stdout.write("No options provided: only checking projects with run_iati_checks=True")
  +            projects = projects.filter(run_iati_checks=True)
  +        elif all_option:
  +            self.stdout.write("Checking ALL projects. This might take a while...")
  +        else:
  +            if date_start:
  +                self.stdout.write("Filtering projects on and after %s" % date_start)
  +                projects = projects.filter(created_at__gte=date_start)
  +            if date_end:
  +                self.stdout.write("Filtering projects on and before %s" % date_end)
  +                projects = projects.filter(created_at__lte=date_end)
  +
           self.stdout.write('Performing IATI checks for {} ...'.format(projects.count()))
           for project in projects:
               self.stdout.write('Performing IATI checks for project {0}...'.format(project.pk))
  
verification_info: {"golden_diff": "diff --git a/akvo/rsr/management/commands/perform_iati_checks.py b/akvo/rsr/management/commands/perform_iati_checks.py\n--- a/akvo/rsr/management/commands/perform_iati_checks.py\n+++ b/akvo/rsr/management/commands/perform_iati_checks.py\n@@ -3,25 +3,60 @@\n # Akvo Reporting is covered by the GNU Affero General Public License.\n # See more details in the license.txt file located at the root folder of the Akvo RSR module.\n # For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.\n+import argparse\n+import datetime\n \n from akvo.rsr.models.project import Project\n \n from django.core.management.base import BaseCommand\n \n \n+def date_arg_type(string):\n+    return datetime.datetime.strptime(string, '%Y-%m-%d').date()\n+\n+\n class Command(BaseCommand):\n     help = \"Perform all IATI checks for projects.\"\n \n-    def add_arguments(self, parser):\n+    def add_arguments(self, parser: argparse.ArgumentParser):\n         parser.add_argument(\n             '--all',\n             action='store_true',\n             default=False,\n             help='Run IATI checks for all the projects in the DB.',\n+\n+        )\n+        parser.add_argument(\n+            '--date-start',\n+            type=date_arg_type,\n+            help='Limit to projects created on and after this day',\n+        )\n+        parser.add_argument(\n+            '--date-end',\n+            type=date_arg_type,\n+            help='Limit to projects created on or before this day',\n         )\n \n     def handle(self, *args, **options):\n-        projects = Project.objects.all() if options['all'] else Project.objects.filter(run_iati_checks=True)\n+        all_option = options[\"all\"]\n+        date_start = options[\"date_start\"]\n+        date_end = options[\"date_end\"]\n+\n+        # Filter projects with options\n+        projects = Project.objects.all()\n+        if not (all_option or date_start or date_end):\n+            self.stdout.write(\"No options provided: only checking projects with run_iati_checks=True\")\n+            projects = projects.filter(run_iati_checks=True)\n+        elif all_option:\n+            self.stdout.write(\"Checking ALL projects. This might take a while...\")\n+        else:\n+            if date_start:\n+                self.stdout.write(\"Filtering projects on and after %s\" % date_start)\n+                projects = projects.filter(created_at__gte=date_start)\n+            if date_end:\n+                self.stdout.write(\"Filtering projects on and before %s\" % date_end)\n+                projects = projects.filter(created_at__lte=date_end)\n+\n         self.stdout.write('Performing IATI checks for {} ...'.format(projects.count()))\n         for project in projects:\n             self.stdout.write('Performing IATI checks for project {0}...'.format(project.pk))\n", "issue": "Allow passing date range for perform_iati_checks\nCurrently, [`perform_iati_checks`](https://github.com/akvo/akvo-rsr/blob/master/akvo/rsr/management/commands/perform_iati_checks.py) only has the `--all` option. It should be possible to pass a date range of projects to execute the script on.\r\n\r\nExecuting it on all projects is unnecessary as most are probably inactive.\r\n\r\nThis is related to #4779 as some project will have to be rechecked and we don't want to check all projects.\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\n# Akvo Reporting is covered by the GNU Affero General Public License.\n# See more details in the license.txt file located at the root folder of the Akvo RSR module.\n# For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.\n\nfrom akvo.rsr.models.project import Project\n\nfrom django.core.management.base import BaseCommand\n\n\nclass Command(BaseCommand):\n    help = \"Perform all IATI checks for projects.\"\n\n    def add_arguments(self, parser):\n        parser.add_argument(\n            '--all',\n            action='store_true',\n            default=False,\n            help='Run IATI checks for all the projects in the DB.',\n        )\n\n    def handle(self, *args, **options):\n        projects = Project.objects.all() if options['all'] else Project.objects.filter(run_iati_checks=True)\n        self.stdout.write('Performing IATI checks for {} ...'.format(projects.count()))\n        for project in projects:\n            self.stdout.write('Performing IATI checks for project {0}...'.format(project.pk))\n            project.update_iati_checks()\n", "path": "akvo/rsr/management/commands/perform_iati_checks.py"}]}