comment out strange command we may never use

This commit is contained in:
Kenneth Kehl
2024-10-02 14:04:26 -07:00
parent 6e73e81201
commit 05a6a2a4d9

View File

@@ -24,12 +24,6 @@ from app.dao.annual_billing_dao import (
dao_create_or_update_annual_billing_for_year, dao_create_or_update_annual_billing_for_year,
set_default_free_allowance_for_service, set_default_free_allowance_for_service,
) )
from app.dao.fact_billing_dao import (
delete_billing_data_for_service_for_day,
fetch_billing_data_for_day,
get_service_ids_that_need_billing_populated,
update_fact_billing,
)
from app.dao.jobs_dao import dao_get_job_by_id from app.dao.jobs_dao import dao_get_job_by_id
from app.dao.organization_dao import ( from app.dao.organization_dao import (
dao_add_service_to_organization, dao_add_service_to_organization,
@@ -63,7 +57,7 @@ from app.models import (
TemplateHistory, TemplateHistory,
User, User,
) )
from app.utils import get_midnight_in_utc, utc_now from app.utils import utc_now
from notifications_utils.recipients import RecipientCSV from notifications_utils.recipients import RecipientCSV
from notifications_utils.template import SMSMessageTemplate from notifications_utils.template import SMSMessageTemplate
from tests.app.db import ( from tests.app.db import (
@@ -167,76 +161,78 @@ def purge_functional_test_data(user_email_prefix):
delete_model_user(usr) delete_model_user(usr)
@notify_command(name="insert-inbound-numbers") # TODO maintainability what is the purpose of this command? Who would use it and why?
@click.option( # COMMENTING OUT UNTIL WE DETERMINE IF WE NEED IT OR NOT
"-f", # @notify_command(name="insert-inbound-numbers")
"--file_name", # @click.option(
required=True, # "-f",
help="""Full path of the file to upload, file is a contains inbound numbers, one number per line.""", # "--file_name",
) # required=True,
def insert_inbound_numbers_from_file(file_name): # help="""Full path of the file to upload, file is a contains inbound numbers, one number per line.""",
# TODO maintainability what is the purpose of this command? Who would use it and why? # )
# def insert_inbound_numbers_from_file(file_name):
current_app.logger.info(f"Inserting inbound numbers from {file_name}") # current_app.logger.info(f"Inserting inbound numbers from {file_name}")
with open(file_name) as file: # with open(file_name) as file:
sql = text( # sql = text(
"insert into inbound_numbers values(:uuid, :line, 'sns', null, True, now(), null);" # "insert into inbound_numbers values(:uuid, :line, 'sns', null, True, now(), null);"
) # )
for line in file: # for line in file:
line = line.strip() # line = line.strip()
if line: # if line:
current_app.logger.info(line) # current_app.logger.info(line)
db.session.execute(sql, {"uuid": str(uuid.uuid4()), "line": line}) # db.session.execute(sql, {"uuid": str(uuid.uuid4()), "line": line})
db.session.commit() # db.session.commit()
def setup_commands(application): def setup_commands(application):
application.cli.add_command(command_group) application.cli.add_command(command_group)
@notify_command(name="rebuild-ft-billing-for-day") # TODO maintainability what is the purpose of this command? Who would use it and why?
@click.option("-s", "--service_id", required=False, type=click.UUID) # COMMENTING OUT UNTIL WE DETERMINE IF WE NEED IT OR NOT
@click.option( # @notify_command(name="rebuild-ft-billing-for-day")
"-d", # @click.option("-s", "--service_id", required=False, type=click.UUID)
"--day", # @click.option(
help="The date to recalculate, as YYYY-MM-DD", # "-d",
required=True, # "--day",
type=click_dt(format="%Y-%m-%d"), # help="The date to recalculate, as YYYY-MM-DD",
) # required=True,
def rebuild_ft_billing_for_day(service_id, day): # type=click_dt(format="%Y-%m-%d"),
# TODO maintainability what is the purpose of this command? Who would use it and why? # )
# def rebuild_ft_billing_for_day(service_id, day):
""" # """
Rebuild the data in ft_billing for the given service_id and date # Rebuild the data in ft_billing for the given service_id and date
""" # """
def rebuild_ft_data(process_day, service): # def rebuild_ft_data(process_day, service):
deleted_rows = delete_billing_data_for_service_for_day(process_day, service) # deleted_rows = delete_billing_data_for_service_for_day(process_day, service)
current_app.logger.info( # current_app.logger.info(
f"deleted {deleted_rows} existing billing rows for {service} on {process_day}" # f"deleted {deleted_rows} existing billing rows for {service} on {process_day}"
) # )
transit_data = fetch_billing_data_for_day( # transit_data = fetch_billing_data_for_day(
process_day=process_day, service_id=service # process_day=process_day, service_id=service
) # )
# transit_data = every row that should exist # # transit_data = every row that should exist
for data in transit_data: # for data in transit_data:
# upsert existing rows # # upsert existing rows
update_fact_billing(data, process_day) # update_fact_billing(data, process_day)
current_app.logger.info( # current_app.logger.info(
f"added/updated {len(transit_data)} billing rows for {service} on {process_day}" # f"added/updated {len(transit_data)} billing rows for {service} on {process_day}"
) # )
if service_id: # if service_id:
# confirm the service exists # # confirm the service exists
dao_fetch_service_by_id(service_id) # dao_fetch_service_by_id(service_id)
rebuild_ft_data(day, service_id) # rebuild_ft_data(day, service_id)
else: # else:
services = get_service_ids_that_need_billing_populated( # services = get_service_ids_that_need_billing_populated(
get_midnight_in_utc(day), get_midnight_in_utc(day + timedelta(days=1)) # get_midnight_in_utc(day), get_midnight_in_utc(day + timedelta(days=1))
) # )
for row in services: # for row in services:
rebuild_ft_data(day, row.service_id) # rebuild_ft_data(day, row.service_id)
@notify_command(name="bulk-invite-user-to-service") @notify_command(name="bulk-invite-user-to-service")
@@ -472,29 +468,30 @@ def associate_services_to_organizations():
current_app.logger.info("finished associating services to organizations") current_app.logger.info("finished associating services to organizations")
@notify_command(name="populate-service-volume-intentions") # TODO maintainability what is the purpose of this command? Who would use it and why?
@click.option( # COMMENTING OUT UNTIL WE DETERMINE IF WE NEED IT OR NOT
"-f", # @notify_command(name="populate-service-volume-intentions")
"--file_name", # @click.option(
required=True, # "-f",
help="Pipe delimited file containing service_id, SMS, email", # "--file_name",
) # required=True,
def populate_service_volume_intentions(file_name): # help="Pipe delimited file containing service_id, SMS, email",
# [0] service_id # )
# [1] SMS:: volume intentions for service # def populate_service_volume_intentions(file_name):
# [2] Email:: volume intentions for service # # [0] service_id
# # [1] SMS:: volume intentions for service
# # [2] Email:: volume intentions for service
# TODO maintainability what is the purpose of this command? Who would use it and why?
with open(file_name, "r") as f: # with open(file_name, "r") as f:
for line in itertools.islice(f, 1, None): # for line in itertools.islice(f, 1, None):
columns = line.split(",") # columns = line.split(",")
current_app.logger.info(columns) # current_app.logger.info(columns)
service = dao_fetch_service_by_id(columns[0]) # service = dao_fetch_service_by_id(columns[0])
service.volume_sms = columns[1] # service.volume_sms = columns[1]
service.volume_email = columns[2] # service.volume_email = columns[2]
dao_update_service(service) # dao_update_service(service)
current_app.logger.info("populate-service-volume-intentions complete") # current_app.logger.info("populate-service-volume-intentions complete")
@notify_command(name="populate-go-live") @notify_command(name="populate-go-live")