Merge pull request #1844 from alphagov/zendesk

zendesk instead of deskpro
This commit is contained in:
Leo Hemsted
2018-04-27 16:59:08 +01:00
committed by GitHub
7 changed files with 60 additions and 64 deletions

View File

@@ -8,7 +8,7 @@ from flask_sqlalchemy import SQLAlchemy
from flask_marshmallow import Marshmallow
from flask_migrate import Migrate
from monotonic import monotonic
from notifications_utils.clients import DeskproClient
from notifications_utils.clients.zendesk.zendesk_client import ZendeskClient
from notifications_utils.clients.statsd.statsd_client import StatsdClient
from notifications_utils.clients.redis.redis_client import RedisClient
from notifications_utils import logging, request_helper
@@ -36,7 +36,7 @@ loadtest_client = LoadtestingClient()
mmg_client = MMGClient()
aws_ses_client = AwsSesClient()
encryption = Encryption()
deskpro_client = DeskproClient()
zendesk_client = ZendeskClient()
statsd_client = StatsdClient()
redis_store = RedisClient()
performance_platform_client = PerformancePlatformClient()
@@ -62,7 +62,7 @@ def create_app(application):
db.init_app(application)
migrate.init_app(application, db=db)
ma.init_app(application)
deskpro_client.init_app(application)
zendesk_client.init_app(application)
statsd_client.init_app(application)
logging.init_app(application, statsd_client)
firetext_client.init_app(application, statsd_client=statsd_client)

View File

@@ -12,15 +12,13 @@ from sqlalchemy import and_, func
from sqlalchemy.exc import SQLAlchemyError
from app import notify_celery
from app import performance_platform_client, deskpro_client
from app import performance_platform_client, zendesk_client
from app.aws import s3
from app.celery.service_callback_tasks import (
send_delivery_status_to_service,
create_encrypted_callback_data,
)
from app.celery.tasks import (
process_job
)
from app.celery.tasks import process_job
from app.config import QueueNames, TaskNames
from app.dao.date_util import get_month_start_and_end_date_in_utc
from app.dao.inbound_sms_dao import delete_inbound_sms_created_more_than_a_week_ago
@@ -379,10 +377,10 @@ def raise_alert_if_letter_notifications_still_sending():
)
# Only send alerts in production
if current_app.config['NOTIFY_ENVIRONMENT'] in ['live', 'production', 'test']:
deskpro_client.create_ticket(
zendesk_client.create_ticket(
subject="[{}] Letters still sending".format(current_app.config['NOTIFY_ENVIRONMENT']),
message=message,
ticket_type="alert"
ticket_type=zendesk_client.TYPE_INCIDENT
)
else:
current_app.logger.info(message)
@@ -513,25 +511,29 @@ def letter_raise_alert_if_no_ack_file_for_zip():
s = zip_file.split('|')
ack_content_set.add(s[0].upper())
deskpro_message = "Letter ack file does not contains all zip files sent. " \
"Missing ack for zip files: {}, " \
"pdf bucket: {}, subfolder: {}, " \
"ack bucket: {}".format(str(sorted(zip_file_set - ack_content_set)),
current_app.config['LETTERS_PDF_BUCKET_NAME'],
datetime.utcnow().strftime('%Y-%m-%d') + '/zips_sent',
current_app.config['DVLA_RESPONSE_BUCKET_NAME'])
message = (
"Letter ack file does not contain all zip files sent. "
"Missing ack for zip files: {}, "
"pdf bucket: {}, subfolder: {}, "
"ack bucket: {}"
).format(
str(sorted(zip_file_set - ack_content_set)),
current_app.config['LETTERS_PDF_BUCKET_NAME'],
datetime.utcnow().strftime('%Y-%m-%d') + '/zips_sent',
current_app.config['DVLA_RESPONSE_BUCKET_NAME']
)
# strip empty element before comparison
ack_content_set.discard('')
zip_file_set.discard('')
if len(zip_file_set - ack_content_set) > 0:
if current_app.config['NOTIFY_ENVIRONMENT'] in ['live', 'production', 'test']:
deskpro_client.create_ticket(
zendesk_client.create_ticket(
subject="Letter acknowledge error",
message=deskpro_message,
ticket_type='alert'
message=message,
ticket_type=zendesk_client.TYPE_INCIDENT
)
current_app.logger.error(deskpro_message)
current_app.logger.error(message)
if len(ack_content_set - zip_file_set) > 0:
current_app.logger.info(

View File

@@ -102,13 +102,8 @@ class Config(object):
PERFORMANCE_PLATFORM_ENABLED = False
PERFORMANCE_PLATFORM_URL = 'https://www.performance.service.gov.uk/data/govuk-notify/'
# Deskpro
DESKPRO_API_HOST = os.environ.get('DESKPRO_API_HOST')
DESKPRO_API_KEY = os.environ.get('DESKPRO_API_KEY')
DESKPRO_DEPT_ID = 5
DESKPRO_ASSIGNED_AGENT_TEAM_ID = 5
DESKPRO_PERSON_EMAIL = 'donotreply@notifications.service.gov.uk'
# Zendesk
ZENDESK_API_KEY = os.environ.get('ZENDESK_API_KEY')
# Logging
DEBUG = False