Skip to content

Commit

Permalink
Merge pull request #1704 from GSA/main
Browse files Browse the repository at this point in the history
07/05/2024 Production Deploy
  • Loading branch information
ccostino authored Jul 5, 2024
2 parents 62521e7 + 3a2ba3a commit f52d998
Show file tree
Hide file tree
Showing 16 changed files with 532 additions and 648 deletions.
11 changes: 6 additions & 5 deletions app/assets/javascripts/sampleChartDashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
});

var socket = io();
var serviceId = ctx.getAttribute('data-service-id');

socket.on('connect', function() {
socket.emit('fetch_daily_stats', serviceId);
socket.emit('fetch_daily_stats_by_user');
});

socket.on('daily_stats_update', function(data) {
socket.on('daily_stats_by_user_update', function(data) {
// console.log('Data received:', data);
var labels = [];
var deliveredData = [];

Expand All @@ -50,13 +50,14 @@
});

socket.on('error', function(data) {
console.log('Error:', data);
// console.log('Error:', data);
});

var sevenDaysButton = document.getElementById('sevenDaysButton');
if (sevenDaysButton) {
sevenDaysButton.addEventListener('click', function() {
socket.emit('fetch_daily_stats', serviceId);
socket.emit('fetch_daily_stats_by_user');
// console.log('clicked');
});
}
}
Expand Down
4 changes: 4 additions & 0 deletions app/assets/sass/uswds/_legacy-styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ h2.sms-message-header {
margin-bottom: 0.5rem;
}

.usa-prose >*+ h2.message-header {
margin-top: 1em;
}

h2.recipient-list {
margin-bottom: 0.5rem;
}
Expand Down
23 changes: 21 additions & 2 deletions app/main/views/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@


@socketio.on("fetch_daily_stats")
def handle_fetch_daily_stats(service_id):
def handle_fetch_daily_stats():
service_id = session.get('service_id')
if service_id:
date_range = get_stats_date_range()
daily_stats = service_api_client.get_service_notification_statistics_by_day(
Expand All @@ -46,6 +47,25 @@ def handle_fetch_daily_stats(service_id):
emit("error", {"error": "No service_id provided"})


@socketio.on("fetch_daily_stats_by_user")
def handle_fetch_daily_stats_by_user():
service_id = session.get("service_id")
user_id = session.get("user_id")
if service_id and user_id:
date_range = get_stats_date_range()
daily_stats_by_user = (
service_api_client.get_user_service_notification_statistics_by_day(
service_id,
user_id,
start_date=date_range["start_date"],
days=date_range["days"],
)
)
emit("daily_stats_by_user_update", daily_stats_by_user)
else:
emit("error", {"error": "No service_id or user_id provided"})


@main.route("/services/<uuid:service_id>/dashboard")
@user_has_permissions("view_activity", "send_messages")
def old_service_dashboard(service_id):
Expand Down Expand Up @@ -98,7 +118,6 @@ def service_dashboard(service_id):
partials=get_dashboard_partials(service_id),
job_and_notifications=job_and_notifications,
service_data_retention_days=service_data_retention_days,
service_id=service_id,
)


Expand Down
4 changes: 2 additions & 2 deletions app/main/views/tour.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,10 @@ def check_tour_notification(service_id, template_id):
)

return render_template(
"views/notifications/check.html",
"views/notifications/preview.html",
template=template,
back_link=back_link,
help="2",
help="3",
)


Expand Down
14 changes: 13 additions & 1 deletion app/notify_client/service_api_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import datetime
from datetime import datetime, timezone

from app.extensions import redis_client
from app.notify_client import NotifyAdminAPIClient, _attach_current_user, cache
Expand Down Expand Up @@ -53,6 +53,18 @@ def get_service_notification_statistics_by_day(
"/service/{0}/statistics/{1}/{2}".format(service_id, start_date, days),
)["data"]

def get_user_service_notification_statistics_by_day(
self, service_id, user_id, start_date=None, days=None
):
if start_date is None:
start_date = datetime.now(timezone.utc).strftime("%Y-%m-%d")

return self.get(
"/service/{0}/statistics/user/{1}/{2}/{3}".format(
service_id, user_id, start_date, days
),
)["data"]

def get_services(self, params_dict=None):
"""
Retrieve a list of services.
Expand Down
2 changes: 1 addition & 1 deletion app/templates/views/dashboard/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h2 class="font-body-2xl line-height-sans-2 margin-0">
</h2>

<!-- <button id="sevenDaysButton">7 Days</button>
<canvas id="myChart" data-service-id="{{ service_id }}"></canvas> -->
<canvas id="myChart"></canvas> -->
{{ ajax_block(partials, updates_url, 'inbox') }}

{{ ajax_block(partials, updates_url, 'totals') }}
Expand Down
37 changes: 27 additions & 10 deletions app/templates/views/notifications/preview.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,21 @@
{% from "components/components/button/macro.njk" import usaButton %}

{% block service_page_title %}
{{ "Error" if error else "Preview" }}
{% if error %}
{{ "Error" }}
{% elif help %}
{{ "Example text message" }}
{% else %}
{{ "Preview" }}
{% endif %}
{% endblock %}

{% block backLink %}
{{ usaBackLink({ "href": back_link_from_preview }) }}
{% if help %}
{{ usaBackLink({ "href": back_link }) }}
{% else %}
{{ usaBackLink({ "href": back_link_from_preview }) }}
{% endif %}
{% endblock %}

{% block maincolumn_content %}
Expand Down Expand Up @@ -40,16 +50,23 @@
{% endcall %}
</div>
{% else %}
{{ page_header('Preview') }}
{{ page_header("Example text message" if help else "Preview") }}
{% endif %}
<div>
<p class="sms-message-scheduler">Scheduled: {{ scheduled_for |format_datetime_scheduled_notification if scheduled_for else 'Now'}}</p>
<p class="sms-message-template">Template: {{template.name}}</p>
<p class="sms-message-sender" >From: {{ template.sender }}</p>
<p class="sms-message-sender" >To: {{ recipient }}</p>
</div>

<h2 id="{{ file_contents_header_id }}">Message</h2>
{% if not help %}
<div>
<p class="sms-message-scheduler">Scheduled: {{ scheduled_for |format_datetime_scheduled_notification if scheduled_for else 'Now'}}</p>
<p class="sms-message-template">Template: {{template.name}}</p>
<p class="sms-message-sender" >From: {{ template.sender }}</p>
<p class="sms-message-sender" >To: {{ recipient }}</p>
</div>
{% endif %}

{% if not help %}
<h2 class="message-header">Message</h2>
{% endif %}


<div class="preview-message"> {{ template|string }}</div>

<div class="js-stick-at-bottom-when-scrolling">
Expand Down
1 change: 0 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ plugins.addSrc = require('gulp-add-src');
plugins.babel = require('gulp-babel');
plugins.cleanCSS = require('gulp-clean-css');
plugins.concat = require('gulp-concat');
plugins.cssUrlAdjuster = require('gulp-css-url-adjuster');
plugins.jshint = require('gulp-jshint');
plugins.prettyerror = require('gulp-prettyerror');
plugins.rollup = require('gulp-better-rollup')
Expand Down
3 changes: 2 additions & 1 deletion gunicorn_config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import multiprocessing
import os
import sys
import traceback
import multiprocessing

import gunicorn

# Let gunicorn figure out the right number of workers
Expand Down
Loading

0 comments on commit f52d998

Please sign in to comment.