Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1#!/usr/local/bin/python 

2# encoding: utf-8 

3""" 

4*The data model module for the `services_refresh_sidebar_list_counts` resource* 

5 

6:Author: 

7 David Young 

8""" 

9from builtins import object 

10import sys 

11import os 

12import khufu 

13 

14class services_refresh_sidebar_list_counts(object): 

15 """ 

16 The worker class for the services_refresh_sidebar_list_counts module 

17 

18 **Key Arguments** 

19 

20 - ``log`` -- logger 

21 - ``request`` -- the pyramid request 

22 - ``elementId`` -- the specific element id requests (or False) 

23  

24 """ 

25 

26 def __init__( 

27 self, 

28 log, 

29 request, 

30 elementId=False 

31 ): 

32 self.log = log 

33 self.request = request 

34 self.elementId = elementId 

35 # xt-self-arg-tmpx 

36 

37 log.debug( 

38 "instansiating a new 'services_refresh_sidebar_list_counts' object") 

39 return None 

40 

41 def close(self): 

42 del self 

43 return None 

44 

45 def put(self): 

46 """execute the put method on the services_refresh_sidebar_list_counts object 

47 

48 **Return** 

49 

50 - ``responseContent`` -- the reponse to send to the browser 

51  

52 """ 

53 self.log.debug('starting the ``put`` method') 

54 

55 # all marshall workflow list titles 

56 marshallWorkflowLists = ["inbox", "archive", "following", "pending observation", 

57 "followup complete", "review for followup", "pending classification"] 

58 

59 # count objects in each list and update the `meta_workflow_lists_counts` 

60 # table 

61 for thisList in marshallWorkflowLists: 

62 sqlListName = thisList.replace(" ", "_") 

63 sqlQuery = """update meta_workflow_lists_counts set count = (select count(*) from pesstoObjects where marshallWorkflowLocation="%(thisList)s") where listname = "%(thisList)s" """ % locals( 

64 ) 

65 self.request.db.execute(sqlQuery) 

66 self.request.db.commit() 

67 

68 # content for response 

69 responseContent = "updated `marshallWorkflowLocations` in `meta_workflow_lists_counts` table" 

70 

71 # all alert workflow list titles 

72 alertWorkflowLists = [ 

73 "external alert released", "pessto classification released", "archived without alert", "queued for atel"] 

74 

75 # count objects in each list and update the `meta_workflow_lists_counts` 

76 # table 

77 for thisList in alertWorkflowLists: 

78 sqlListName = thisList.replace(" ", "_") 

79 sqlQuery = """update meta_workflow_lists_counts set count = (select count(*) from pesstoObjects where alertWorkflowLocation="%(thisList)s") where listname = "%(thisList)s" """ % locals( 

80 ) 

81 self.request.db.execute(sqlQuery) 

82 self.request.db.commit() 

83 

84 # count all objects 

85 sqlQuery = """update meta_workflow_lists_counts set count = (select count(*) from pesstoObjects) where listname = "all" """ % locals( 

86 ) 

87 self.request.db.execute(sqlQuery) 

88 self.request.db.commit() 

89 

90 # content for response 

91 responseContent += "<BR>updated `alertWorkflowLocation` in `meta_workflow_lists_counts` table" 

92 

93 # count classified objects 

94 sqlQuery = """update meta_workflow_lists_counts set count = (select count(*) from pesstoObjects where classifiedFlag = 1) where listname = "classified" """ % locals( 

95 ) 

96 self.request.db.execute(sqlQuery) 

97 self.request.db.commit() 

98 

99 # content for response 

100 responseContent += "<BR>updated `classified` list in `meta_workflow_lists_counts` table" 

101 

102 # count snoozed objects 

103 sqlQuery = """update meta_workflow_lists_counts set count = (select count(*) from pesstoObjects where snoozed = 1) where listname = "snoozed" """ % locals( 

104 ) 

105 self.request.db.execute(sqlQuery) 

106 self.request.db.commit() 

107 

108 # content for response 

109 responseContent += "<BR>updated `snoozed` list in `meta_workflow_lists_counts` table" 

110 

111 self.log.debug('completed the ``put`` method') 

112 return responseContent 

113 

114 # xt-class-method