Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command to requeue form repeaters using app_id, form_name and submission time #35457

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sravfeyn
Copy link
Member

Product Description

Adhoc command to facilitate requeuing form repeaters

Technical Summary

Feature Flag

NA

Safety Assurance

Tested locally, relies on existing requeue functions

Safety story

Automated test coverage

NA

QA Plan

Tested locally

Rollback instructions

  • This PR can be reverted after deploy with no further considerations

Labels & Review

  • Risk label is set correctly
  • The set of people pinged as reviewers is appropriate for the level of risk of the change

Copy link
Contributor

@kaapstorm kaapstorm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple of suggestions.

"""
Parses the input CSV data, stripping any extra spaces around values.
"""
reader = csv.reader(csv_data.strip().splitlines())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that fileinput in the standard library might be able to make this a little simpler.

import fileinput

.. and then instead of sys.stdin.read() and ....splitlines() you can use this:

Suggested change
reader = csv.reader(csv_data.strip().splitlines())
with fileinput.input() as csv_data:
reader = csv.reader(csv_data)

def process_requeue_forms(self, requeue_forms, soft_run=True):
for extra, domain, app_id, form_name, form_xmlns, startdate, enddate, repeater_id in requeue_forms:
startdate = datetime.datetime.strptime(startdate, "%d-%m-%Y").date()
enddate = datetime.datetime.strptime(enddate, "%d-%m-%Y").date()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh boy, the Americans are going to be so confused. How about,

from datetime import date

... and then

Suggested change
enddate = datetime.datetime.strptime(enddate, "%d-%m-%Y").date()
enddate = date.fromisoformat(enddate)

? That way startdate and enddate can be formatted using any valid ISO 8601 format, e.g. "2024-11-30" or "20241130".



class Command(BaseCommand):
help = "Requeue forms by inputting appi_id, form_name and submission times"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo

Suggested change
help = "Requeue forms by inputting appi_id, form_name and submission times"
help = "Requeue forms by inputting app_id, form_name and submission times"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants