Correct subject formatting

Change-Id: I5e744d48f3c971c99def9594da3a80d9625e856b
Related-bug: PROD-24843 (PROD:24843)
diff --git a/sf_notifier/helpers.py b/sf_notifier/helpers.py
index 8a5bf8d..de02814 100644
--- a/sf_notifier/helpers.py
+++ b/sf_notifier/helpers.py
@@ -15,10 +15,19 @@
 
 
 RESOLVED_STATUSES = ('UP', 'OK', 'resolved')
-SUBJECT_FMT = '[{}][{}] {}'
 
 
-def alert_fields_and_action(alert):
+def _format_subject(alert, env):
+    subject = '[{}]'.format(alert['labels'].get('environment', env))
+
+    host = alert['labels'].get('host')
+    if host is not None:
+        subject = '{}[{}]'.format(subject, host)
+
+    return '{} {}'.format(subject, alert['annotations']['summary'])
+
+
+def alert_fields_and_action(alert, env):
     fields = []
 
     if alert['status'] in RESOLVED_STATUSES:
@@ -26,11 +35,8 @@
         fields.append(alert['labels'])
     else:
         action = 'create_case'
-        # Order matters
-        subject = SUBJECT_FMT.format(alert['labels']['environment'],
-                                     alert['labels'].get('host', 'none'),
-                                     alert['annotations']['summary'])
-        fields.append(subject)
+        # Order of keys matters
+        fields.append(_format_subject(alert, env))
         fields.append(alert['annotations']['description'])
         fields.append(alert['status'])
         fields.append(alert['labels'])