We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
#6963 Too many codes in 1 package
URL: https://meinberlin-dev.liqd.net/dashboard/modules/burgerinnenhaushalt-3-phasen-21/download-codes/
user: admin, initiator
expected behaviour: Each code-package should contain a max. of 1.000.000 codes. ~~The wording of the helptext should have also the right number of 1.000.000 codes per package as each package should contain a maximum of 1.000.000 codes per excel-file.~~
behaviour: ~~the number in the wording of the helptext is "10.000.000" and~~ the packages can contain more than 1.000.000 codes.
important screensize: -
device & browser: mac ff
Comment/Question: I tried it with generating two mill codes and the codes were put in only one code-package. I also couldn't download the package probably because it was too big.

Linked: https://github.com/liqd/a4-meinberlin/issues/4907


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `meinberlin/apps/votes/tasks.py`
Content:
```
1 from background_task import background
2 
3 from adhocracy4.modules.models import Module
4 from meinberlin.apps.votes.models import VotingToken
5 from meinberlin.apps.votes.models import get_token_12
6 
7 # Number of tokens to insert into database per bulk_create
8 BATCH_SIZE = 1000000
9 # Max number of tokens in one download / package
10 PACKAGE_SIZE = 10000000
11 
12 
13 def generate_voting_tokens(module_id, number_of_tokens, existing_tokens):
14     module = Module.objects.get(pk=module_id)
15     package_number = VotingToken.next_package_number(module)
16     module_name = module.name
17     project_id = module.project.id
18     project_name = module.project.name
19 
20     number_to_generate = number_of_tokens
21     package_number_limit = 0
22     if number_of_tokens > PACKAGE_SIZE:
23         package_number_limit = number_of_tokens - PACKAGE_SIZE
24     while number_to_generate > 0:
25         if number_to_generate >= BATCH_SIZE:
26             generate_voting_tokens_batch(
27                 module_id,
28                 BATCH_SIZE,
29                 package_number,
30                 number_of_tokens,
31                 module_name,
32                 project_id,
33                 project_name,
34                 existing_tokens,
35             )
36             number_to_generate = number_to_generate - BATCH_SIZE
37         else:
38             generate_voting_tokens_batch(
39                 module_id,
40                 number_to_generate,
41                 package_number,
42                 number_of_tokens,
43                 module_name,
44                 project_id,
45                 project_name,
46                 existing_tokens,
47             )
48             number_to_generate = 0
49         if package_number_limit >= number_to_generate:
50             package_number += 1
51             package_number_limit - PACKAGE_SIZE
52 
53 
54 @background(schedule=1)
55 def generate_voting_tokens_batch(
56     module_id,
57     batch_size,
58     package_number,
59     number_of_tokens,
60     module_name,
61     project_id,
62     project_name,
63     existing_tokens,
64 ):
65     module = Module.objects.get(pk=module_id)
66     VotingToken.objects.bulk_create(
67         [get_token_and_hash(module, package_number) for i in range(batch_size)]
68     )
69 
70 
71 def get_token_and_hash(module, package_number):
72     token = get_token_12()
73     token_hash = VotingToken.hash_token(token, module)
74     return VotingToken(
75         token=token, token_hash=token_hash, module=module, package_number=package_number
76     )
77
```
--- 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/meinberlin/apps/votes/tasks.py b/meinberlin/apps/votes/tasks.py
--- a/meinberlin/apps/votes/tasks.py
+++ b/meinberlin/apps/votes/tasks.py
@@ -5,9 +5,9 @@
 from meinberlin.apps.votes.models import get_token_12
 
 # Number of tokens to insert into database per bulk_create
-BATCH_SIZE = 1000000
+BATCH_SIZE = 100000
 # Max number of tokens in one download / package
-PACKAGE_SIZE = 10000000
+PACKAGE_SIZE = 1000000
 
 
 def generate_voting_tokens(module_id, number_of_tokens, existing_tokens):

{"golden_diff": "diff --git a/meinberlin/apps/votes/tasks.py b/meinberlin/apps/votes/tasks.py\n--- a/meinberlin/apps/votes/tasks.py\n+++ b/meinberlin/apps/votes/tasks.py\n@@ -5,9 +5,9 @@\n from meinberlin.apps.votes.models import get_token_12\n \n # Number of tokens to insert into database per bulk_create\n-BATCH_SIZE = 1000000\n+BATCH_SIZE = 100000\n # Max number of tokens in one download / package\n-PACKAGE_SIZE = 10000000\n+PACKAGE_SIZE = 1000000\n \n \n def generate_voting_tokens(module_id, number_of_tokens, existing_tokens):\n", "issue": "#6963 Too many codes in 1 package\nURL: https://meinberlin-dev.liqd.net/dashboard/modules/burgerinnenhaushalt-3-phasen-21/download-codes/\r\nuser: admin, initiator\r\nexpected behaviour: Each code-package should contain a max. of 1.000.000 codes. ~~The wording of the helptext should have also the right number of 1.000.000 codes per package as each package should contain a maximum of 1.000.000 codes per excel-file.~~\r\nbehaviour: ~~the number in the wording of the helptext is \"10.000.000\" and~~ the packages can contain more than 1.000.000 codes.\r\nimportant screensize: -\r\ndevice & browser: mac ff\r\nComment/Question: I tried it with generating two mill codes and the codes were put in only one code-package. I also couldn't download the package probably because it was too big.\r\n\r\nLinked: https://github.com/liqd/a4-meinberlin/issues/4907\r\n\n", "before_files": [{"content": "from background_task import background\n\nfrom adhocracy4.modules.models import Module\nfrom meinberlin.apps.votes.models import VotingToken\nfrom meinberlin.apps.votes.models import get_token_12\n\n# Number of tokens to insert into database per bulk_create\nBATCH_SIZE = 1000000\n# Max number of tokens in one download / package\nPACKAGE_SIZE = 10000000\n\n\ndef generate_voting_tokens(module_id, number_of_tokens, existing_tokens):\n    module = Module.objects.get(pk=module_id)\n    package_number = VotingToken.next_package_number(module)\n    module_name = module.name\n    project_id = module.project.id\n    project_name = module.project.name\n\n    number_to_generate = number_of_tokens\n    package_number_limit = 0\n    if number_of_tokens > PACKAGE_SIZE:\n        package_number_limit = number_of_tokens - PACKAGE_SIZE\n    while number_to_generate > 0:\n        if number_to_generate >= BATCH_SIZE:\n            generate_voting_tokens_batch(\n                module_id,\n                BATCH_SIZE,\n                package_number,\n                number_of_tokens,\n                module_name,\n                project_id,\n                project_name,\n                existing_tokens,\n            )\n            number_to_generate = number_to_generate - BATCH_SIZE\n        else:\n            generate_voting_tokens_batch(\n                module_id,\n                number_to_generate,\n                package_number,\n                number_of_tokens,\n                module_name,\n                project_id,\n                project_name,\n                existing_tokens,\n            )\n            number_to_generate = 0\n        if package_number_limit >= number_to_generate:\n            package_number += 1\n            package_number_limit - PACKAGE_SIZE\n\n\n@background(schedule=1)\ndef generate_voting_tokens_batch(\n    module_id,\n    batch_size,\n    package_number,\n    number_of_tokens,\n    module_name,\n    project_id,\n    project_name,\n    existing_tokens,\n):\n    module = Module.objects.get(pk=module_id)\n    VotingToken.objects.bulk_create(\n        [get_token_and_hash(module, package_number) for i in range(batch_size)]\n    )\n\n\ndef get_token_and_hash(module, package_number):\n    token = get_token_12()\n    token_hash = VotingToken.hash_token(token, module)\n    return VotingToken(\n        token=token, token_hash=token_hash, module=module, package_number=package_number\n    )\n", "path": "meinberlin/apps/votes/tasks.py"}], "after_files": [{"content": "from background_task import background\n\nfrom adhocracy4.modules.models import Module\nfrom meinberlin.apps.votes.models import VotingToken\nfrom meinberlin.apps.votes.models import get_token_12\n\n# Number of tokens to insert into database per bulk_create\nBATCH_SIZE = 100000\n# Max number of tokens in one download / package\nPACKAGE_SIZE = 1000000\n\n\ndef generate_voting_tokens(module_id, number_of_tokens, existing_tokens):\n    module = Module.objects.get(pk=module_id)\n    package_number = VotingToken.next_package_number(module)\n    module_name = module.name\n    project_id = module.project.id\n    project_name = module.project.name\n\n    number_to_generate = number_of_tokens\n    package_number_limit = 0\n    if number_of_tokens > PACKAGE_SIZE:\n        package_number_limit = number_of_tokens - PACKAGE_SIZE\n    while number_to_generate > 0:\n        if number_to_generate >= BATCH_SIZE:\n            generate_voting_tokens_batch(\n                module_id,\n                BATCH_SIZE,\n                package_number,\n                number_of_tokens,\n                module_name,\n                project_id,\n                project_name,\n                existing_tokens,\n            )\n            number_to_generate = number_to_generate - BATCH_SIZE\n        else:\n            generate_voting_tokens_batch(\n                module_id,\n                number_to_generate,\n                package_number,\n                number_of_tokens,\n                module_name,\n                project_id,\n                project_name,\n                existing_tokens,\n            )\n            number_to_generate = 0\n        if package_number_limit >= number_to_generate:\n            package_number += 1\n            package_number_limit - PACKAGE_SIZE\n\n\n@background(schedule=1)\ndef generate_voting_tokens_batch(\n    module_id,\n    batch_size,\n    package_number,\n    number_of_tokens,\n    module_name,\n    project_id,\n    project_name,\n    existing_tokens,\n):\n    module = Module.objects.get(pk=module_id)\n    VotingToken.objects.bulk_create(\n        [get_token_and_hash(module, package_number) for i in range(batch_size)]\n    )\n\n\ndef get_token_and_hash(module, package_number):\n    token = get_token_12()\n    token_hash = VotingToken.hash_token(token, module)\n    return VotingToken(\n        token=token, token_hash=token_hash, module=module, package_number=package_number\n    )\n", "path": "meinberlin/apps/votes/tasks.py"}]}