Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2ea52b1
fix job details
Aug 22, 2025
96b6961
fix test
Aug 22, 2025
8502b6c
fix test
Aug 22, 2025
9ae4075
fix test
Aug 22, 2025
f4b2091
fix test
Aug 22, 2025
07c9d26
fix test
Aug 22, 2025
fb8fed2
fix test
Aug 22, 2025
7f38cee
fix test
Aug 22, 2025
49affd9
fix test
Aug 22, 2025
46a1a92
fix test
Aug 22, 2025
f29ed95
fix test
Aug 22, 2025
c32ece1
Bump lxml from 6.0.0 to 6.0.1 (#1927)
dependabot[bot] Aug 25, 2025
c3e5f0b
Merge pull request #1926 from GSA/job_details
ccostino Aug 25, 2025
86458fe
Added changes to support extra day in activity chart (#1928)
alexjanousekGSA Aug 25, 2025
5b4563c
Bump moto from 5.1.10 to 5.1.11 (#1932)
dependabot[bot] Aug 26, 2025
bf72682
Bump cachetools from 6.1.0 to 6.2.0 (#1929)
dependabot[bot] Aug 26, 2025
866ba24
Bump typing-extensions from 4.14.1 to 4.15.0 (#1930)
dependabot[bot] Aug 26, 2025
255b332
Bump beautifulsoup4 from 4.13.4 to 4.13.5 (#1931)
dependabot[bot] Aug 26, 2025
0a0a3d9
Bump faker from 37.5.3 to 37.6.0
dependabot[bot] Aug 27, 2025
55444db
Merge pull request #1934 from GSA/dependabot/pip/faker-37.6.0
ccostino Aug 27, 2025
52e68eb
Added code to delete files that are stale (#1936)
alexjanousekGSA Aug 27, 2025
cc1909b
Fix Demo environment SSB AWS regions
ccostino Aug 27, 2025
f69d3f1
Merge pull request #1937 from GSA/fix-demo-ssb-references
heyitsmebev Aug 27, 2025
9911060
Bump alembic from 1.16.4 to 1.16.5 (#1938)
dependabot[bot] Aug 28, 2025
9d2a23b
Update Demo SSB References Again
ccostino Aug 28, 2025
6c5534b
Merge pull request #1939 from GSA/fix-demo-ssb-references-again
heyitsmebev Aug 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/celery/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,12 @@ def _generate_notifications_report(service_id, report_id, limit_days):
count = 0
if len(pagination.items) == 0:
current_app.logger.info(f"SKIP {service_id}")

# Delete stale report when there's no new data
_, file_location, _, _, _ = get_csv_location(service_id, report_id)
s3.delete_s3_object(file_location)
current_app.logger.info(f"Deleted stale report {file_location} - no new data")

return
start_time = time.time()
for notification in pagination.items:
Expand Down
3 changes: 2 additions & 1 deletion app/dao/jobs_dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ def dao_get_jobs_by_service_id(
if limit_days is not None:
if use_processing_time:
query_filter.append(
func.coalesce(Job.processing_started, Job.created_at) >= midnight_n_days_ago(limit_days)
func.coalesce(Job.processing_started, Job.created_at)
>= midnight_n_days_ago(limit_days)
)
else:
query_filter.append(Job.created_at >= midnight_n_days_ago(limit_days))
Expand Down
31 changes: 19 additions & 12 deletions app/job/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

from app import db
from app.aws.s3 import (
extract_personalisation,
extract_phones,
get_job_from_s3,
get_job_metadata_from_s3,
get_personalisation_from_s3,
get_phone_number_from_s3,
Expand Down Expand Up @@ -36,7 +39,7 @@
notification_with_template_schema,
notifications_filter_schema,
)
from app.utils import check_suspicious_id, midnight_n_days_ago, pagination_links
from app.utils import check_suspicious_id, hilite, midnight_n_days_ago, pagination_links

job_blueprint = Blueprint("job", __name__, url_prefix="/service/<uuid:service_id>/job")

Expand All @@ -46,6 +49,7 @@

@job_blueprint.route("/<job_id>", methods=["GET"])
def get_job_by_service_and_job_id(service_id, job_id):
current_app.logger.info(hilite("ENTER get_job_by_service_and_job_id"))
check_suspicious_id(service_id, job_id)
job = dao_get_job_by_service_id_and_job_id(service_id, job_id)
statistics = dao_get_notification_outcomes_for_job(service_id, job_id)
Expand All @@ -71,8 +75,12 @@ def cancel_job(service_id, job_id):

@job_blueprint.route("/<job_id>/notifications", methods=["GET"])
def get_all_notifications_for_service_job(service_id, job_id):

check_suspicious_id(service_id, job_id)

job = get_job_from_s3(service_id, job_id)
phones = extract_phones(job, service_id, job_id)
personalisation = extract_personalisation(job)
data = notifications_filter_schema.load(request.args)
page = data["page"] if "page" in data else 1
page_size = (
Expand All @@ -90,21 +98,13 @@ def get_all_notifications_for_service_job(service_id, job_id):

for notification in paginated_notifications.items:
if notification.job_id is not None:
recipient = get_phone_number_from_s3(
notification.service_id,
notification.job_id,
notification.job_row_number,
)
recipient = phones[notification.job_row_number]
notification.to = recipient
notification.normalised_to = recipient

for notification in paginated_notifications.items:
if notification.job_id is not None:
notification.personalisation = get_personalisation_from_s3(
notification.service_id,
notification.job_id,
notification.job_row_number,
)
notification.personalisation = personalisation[notification.job_row_number]

notifications = None
if data.get("format_for_csv"):
Expand All @@ -116,6 +116,7 @@ def get_all_notifications_for_service_job(service_id, job_id):
notifications = notification_with_template_schema.dump(
paginated_notifications.items, many=True
)
current_app.logger.info(hilite("Got the dumped notifications and returning"))

return (
jsonify(
Expand All @@ -134,6 +135,8 @@ def get_all_notifications_for_service_job(service_id, job_id):

@job_blueprint.route("/<job_id>/recent_notifications", methods=["GET"])
def get_recent_notifications_for_service_job(service_id, job_id):

current_app.logger.info(hilite("ENTER get_recent_notifications_for_service_job"))
check_suspicious_id(service_id, job_id)

data = notifications_filter_schema.load(request.args)
Expand Down Expand Up @@ -220,7 +223,9 @@ def get_jobs_by_service(service_id):
else:
limit_days = None

use_processing_time = request.args.get("use_processing_time", "false").lower() == "true"
use_processing_time = (
request.args.get("use_processing_time", "false").lower() == "true"
)

valid_statuses = set(JobStatus)
statuses_arg = request.args.get("statuses", "")
Expand Down Expand Up @@ -332,6 +337,8 @@ def get_paginated_jobs(
statuses,
page,
):

current_app.logger.info(hilite("ENTER get_paginated_jobs"))
pagination = dao_get_jobs_by_service_id(
service_id,
limit_days=limit_days,
Expand Down
4 changes: 2 additions & 2 deletions app/service/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def get_service_notification_statistics(service_id):
data=get_service_statistics(
service_id,
request.args.get("today_only") == "True",
int(request.args.get("limit_days", 7)),
int(request.args.get("limit_days", 8)),
)
)

Expand Down Expand Up @@ -794,7 +794,7 @@ def get_detailed_service(service_id, today_only=False):
return detailed_service_schema.dump(service)


def get_service_statistics(service_id, today_only, limit_days=7):
def get_service_statistics(service_id, today_only, limit_days=8):
check_suspicious_id(service_id)
# today_only flag is used by the send page to work out if the service will exceed their daily usage by sending a job
if today_only:
Expand Down
6 changes: 3 additions & 3 deletions app/template_statistics/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@
@template_statistics.route("")
def get_template_statistics_for_service_by_day(service_id):
check_suspicious_id(service_id)
whole_days = request.args.get("whole_days", request.args.get("limit_days", ""))
whole_days = request.args.get("whole_days", request.args.get("limit_days", "8"))
try:
whole_days = int(whole_days)
except ValueError:
error = f"{whole_days} is not an integer"
message = {"whole_days": [error]}
raise InvalidRequest(message, status_code=400)

if whole_days < 0 or whole_days > 7:
if whole_days < 0 or whole_days > 8:
raise InvalidRequest(
{"whole_days": ["whole_days must be between 0 and 7"]}, status_code=400
{"whole_days": ["whole_days must be between 0 and 8"]}, status_code=400
)
data = fetch_notification_status_for_service_for_today_and_7_previous_days(
service_id, by_template=True, limit_days=whole_days
Expand Down
Loading