From c4c3268dd9ce94a397c07cc028c56d33e7756b56 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Mon, 3 Apr 2017 11:55:30 +0100 Subject: [PATCH] Use a simpler method of generating random number MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: https://github.com/alphagov/notifications-utils/blob/6ddd2ff352b48aa534eba023574bb89dd037fde6/notifications_utils/template.py#L410 --- app/celery/tasks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/celery/tasks.py b/app/celery/tasks.py index 96fbc1d53..f746512be 100644 --- a/app/celery/tasks.py +++ b/app/celery/tasks.py @@ -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) )