Use a simpler method of generating random number

Rather than generating each digit of the number, generate the whole
random number in one go. Should be faster, and is a bit easier to read.

Don’t need to worry about it not being zero-padded because the
`Template` class handles this here:
6ddd2ff352/notifications_utils/template.py (L410)
This commit is contained in:
Chris Hill-Scott
2017-04-03 11:55:30 +01:00
parent 7a412873d3
commit c4c3268dd9

View File

@@ -273,7 +273,7 @@ def build_dvla_file(self, job_id):
notification.personalisation,
# This unique id is a 7 digits requested by DVLA, not known
# if this number needs to be sequential.
numeric_id=int(''.join(map(str, random.sample(range(9), 7)))),
numeric_id=random.randint(1, int('9' * 7)),
))
for notification in dao_get_all_notifications_for_job(job_id)
)