Skip to content

Commit

Permalink
Merge branch 'dev' into test-marshal-DV-4707-1
Browse files Browse the repository at this point in the history
  • Loading branch information
divyav-aot committed Jan 8, 2024
2 parents d083be9 + 87c3b55 commit 907694b
Showing 1 changed file with 31 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,56 @@
import os
from request_api.models.NotificationTypes import NotificationType
from request_api.models.NotificationUserTypes import NotificationUserType
notificationuserfile = open('common/notificationusertypes.json', encoding="utf8")
notificationusertypes_cache = json.load(notificationuserfile)

notificationfile = open('common/notificationtypes.json', encoding="utf8")
notificationtypes_cache = json.load(notificationfile)

class notificationconfig:
""" Notfication config
"""

# This method is used to get the notification user type label
# It first tries to get the notification user type label from the cache
# If it is not found in the cache, it fetches it from the DB
def getnotificationtypelabel(self, notificationtype):
id = NotificationType().getnotificationtypeid(notificationtype)
if id is not None:
return id['notificationtypelabel']
return 0
notificationtype_format = notificationtype.replace(" ", "").lower()
if notificationtype_format in notificationtypes_cache:
return notificationtypes_cache[notificationtype_format]['notificationtypelabel']
else:
print("Notification type not found in cache. Fetching from DB", notificationtype)
id = NotificationType().getnotificationtypeid(notificationtype)
if id is not None:
return id['notificationtypelabel']
return None

def getnotificationtypeid(self, notificationtype):
id = NotificationType().getnotificationtypeid(notificationtype)
if id is not None:
return id['notificationtypeid']
return 0
return None

# This method is used to get the notification user type label
# It first tries to get the notification user type label from the cache
# If it is not found in the cache, it fetches it from the DB
def getnotificationusertypelabel(self, notificationusertype):
id = NotificationUserType().getnotificationusertypesid(notificationusertype)
if id is not None:
return id['notificationusertypelabel']
return 0
notificationusertype_format = notificationusertype.replace(" ", "").lower()
if notificationusertype_format in notificationusertypes_cache:
return notificationusertypes_cache[notificationusertype_format]['notificationusertypelabel']
else:
print("Notification user type not found in cache. Fetching from DB", notificationusertype)
id = NotificationUserType().getnotificationusertypesid(notificationusertype)
if id is not None:
return id['notificationusertypelabel']
return None

def getnotificationusertypeid(self, notificationusertype):
id = NotificationUserType().getnotificationusertypesid(notificationusertype)
if id is not None:
return id['notificationusertypeid']
return 0
return None

def getnotificationdays(self):
if 'FOI_NOTIFICATION_DAYS' in os.environ and os.getenv('FOI_NOTIFICATION_DAYS') != '':
Expand Down

0 comments on commit 907694b

Please sign in to comment.