fix wheel and click_datetime

This commit is contained in:
Kenneth Kehl
2026-01-22 11:25:15 -08:00
parent 96761efa1d
commit 2f6c96f5d0
3 changed files with 52 additions and 65 deletions

View File

@@ -8,7 +8,7 @@ from os import getenv
import click
import flask
from click_datetime import Datetime as click_dt
# from click_datetime import Datetime as click_dt
from faker import Faker
from flask import current_app, json
from sqlalchemy import and_, select, text, update
@@ -260,50 +260,50 @@ def bulk_invite_user_to_service(file_name, service_id, user_id, auth_type, permi
file.close()
@notify_command(name="archive-jobs-created-between-dates")
@click.option(
"-s",
"--start_date",
required=True,
help="start date inclusive",
type=click_dt(format="%Y-%m-%d"),
)
@click.option(
"-e",
"--end_date",
required=True,
help="end date inclusive",
type=click_dt(format="%Y-%m-%d"),
)
def update_jobs_archived_flag(start_date, end_date):
current_app.logger.info(
f"Archiving jobs created between {start_date} to {end_date}"
)
# @notify_command(name="archive-jobs-created-between-dates")
# @click.option(
# "-s",
# "--start_date",
# required=True,
# help="start date inclusive",
# type=click_dt(format="%Y-%m-%d"),
# )
# @click.option(
# "-e",
# "--end_date",
# required=True,
# help="end date inclusive",
# type=click_dt(format="%Y-%m-%d"),
# )
# def update_jobs_archived_flag(start_date, end_date):
# current_app.logger.info(
# f"Archiving jobs created between {start_date} to {end_date}"
# )
process_date = start_date
total_updated = 0
# process_date = start_date
# total_updated = 0
while process_date < end_date:
start_time = utc_now()
sql = """update
jobs set archived = true
where
created_at >= (date :start + time '00:00:00')
and created_at < (date :end + time '00:00:00')
"""
result = db.session.execute(
text(sql), {"start": process_date, "end": process_date + timedelta(days=1)}
)
db.session.commit()
current_app.logger.info(
f"jobs: --- Completed took {datetime.now() - start_time}ms. Archived "
f"{result.rowcount} jobs for {process_date}"
)
# while process_date < end_date:
# start_time = utc_now()
# sql = """update
# jobs set archived = true
# where
# created_at >= (date :start + time '00:00:00')
# and created_at < (date :end + time '00:00:00')
# """
# result = db.session.execute(
# text(sql), {"start": process_date, "end": process_date + timedelta(days=1)}
# )
# db.session.commit()
# current_app.logger.info(
# f"jobs: --- Completed took {datetime.now() - start_time}ms. Archived "
# f"{result.rowcount} jobs for {process_date}"
# )
process_date += timedelta(days=1)
# process_date += timedelta(days=1)
total_updated += result.rowcount
current_app.logger.info(f"Total archived jobs = {total_updated}")
# total_updated += result.rowcount
# current_app.logger.info(f"Total archived jobs = {total_updated}")
@notify_command(name="populate-organizations-from-file")

33
poetry.lock generated
View File

@@ -953,22 +953,6 @@ files = [
[package.dependencies]
colorama = {version = "*", markers = "platform_system == \"Windows\""}
[[package]]
name = "click-datetime"
version = "0.4.0"
description = "Datetime type support for click."
optional = false
python-versions = "<4.0,>=3.12"
groups = ["main"]
files = [
{file = "click_datetime-0.4.0-py3-none-any.whl", hash = "sha256:dfd2f54142f0f899535e400946d724cc8319b4cf70d110d1451f892a6f010b04"},
{file = "click_datetime-0.4.0.tar.gz", hash = "sha256:9f35ed3fab13f553221ce8c5a895e5185d7360993c51dd7f8628b9b4f636930b"},
]
[package.dependencies]
click = ">=8.0.0,<9.0.0"
wheel = ">=0.44.0,<0.45.0"
[[package]]
name = "click-didyoumean"
version = "0.3.1"
@@ -5430,18 +5414,21 @@ watchdog = ["watchdog (>=2.3)"]
[[package]]
name = "wheel"
version = "0.44.0"
description = "A built-package format for Python"
version = "0.46.3"
description = "Command line tool for manipulating wheel files"
optional = false
python-versions = ">=3.8"
python-versions = ">=3.9"
groups = ["main"]
files = [
{file = "wheel-0.44.0-py3-none-any.whl", hash = "sha256:2376a90c98cc337d18623527a97c31797bd02bad0033d41547043a1cbfbe448f"},
{file = "wheel-0.44.0.tar.gz", hash = "sha256:a29c3f2817e95ab89aa4660681ad547c0e9547f20e75b0562fe7723c9a2a9d49"},
{file = "wheel-0.46.3-py3-none-any.whl", hash = "sha256:4b399d56c9d9338230118d705d9737a2a468ccca63d5e813e2a4fc7815d8bc4d"},
{file = "wheel-0.46.3.tar.gz", hash = "sha256:e3e79874b07d776c40bd6033f8ddf76a7dad46a7b8aa1b2787a83083519a1803"},
]
[package.dependencies]
packaging = ">=24.0"
[package.extras]
test = ["pytest (>=6.0.0)", "setuptools (>=65)"]
test = ["pytest (>=6.0.0)", "setuptools (>=77)"]
[[package]]
name = "wrapt"
@@ -5967,4 +5954,4 @@ cffi = ["cffi (>=1.17,<2.0) ; platform_python_implementation != \"PyPy\" and pyt
[metadata]
lock-version = "2.1"
python-versions = "^3.13.2"
content-hash = "6641a18b6df35e762745db5e207a44f892ebe53a9e12899c89e13cd65f4e8707"
content-hash = "ebe791db9beebf608e859ec1c56935f0ee6f40f0443e222218e08586eabde813"

View File

@@ -20,7 +20,6 @@ certifi = ">=2022.12.7"
cffi = "==2.0.0"
charset-normalizer = "^3.4.4"
click = "==8.3.1"
click-datetime = "==0.4.0"
click-didyoumean = "==0.3.1"
click-plugins = "==1.1.1.2"
click-repl = "==0.3.0"
@@ -83,6 +82,7 @@ pytest = "^9.0.2"
filelock = ">=3.20.3"
pyasn1 = ">=0.6.2"
jaraco-context = ">=6.1.0"
wheel = ">=0.46.2"
[tool.poetry.group.dev.dependencies]