Ejemplo n.º 1
0
 def _common_range_query(self, start, end, timestamps):
     q = self.query()
     if start is not None:
         if timestamps:
             start, end = convert_range_to_datetime(start, end)
         q = self._range_filter(q, start, end)
     return q
Ejemplo n.º 2
0
 def _basic_query(self, user_id, 
                  start=None, end=None, timestamps=False):
     q = self.session.query(CaseCurrentStatus)
     q = q.filter_by(handler_id=user_id)
     if start is not None:
         if timestamps:
             start, end = convert_range_to_datetime(start, end)
         q = self._range_filter(q, start, end)
     return q
Ejemplo n.º 3
0
 def _filter_by_status_name_range(self,
                                  status, start, end,
                                  timestamps=False):
     status_id = self.stypes.get_id(status)
     if timestamps:
         start, end = convert_range_to_datetime(start, end)
     q = self.session.query(TicketCurrentStatus)
     q = self._last_change_range(q, start, end)
     return q.filter(TicketCurrentStatus.status == status_id)
Ejemplo n.º 4
0
 def get_unread_calls(self, user_id, start=None,
                        end=None, timestamps=False):
     q = self.query()
     q = q.filter(TicketCurrentStatus.handler_id == user_id)
     if start is not None:
         if timestamps:
             start, end = convert_range_to_datetime(start, end)
         q = self._received_range_filter(q, start, end)
     q = q.filter(TicketCurrentStatus.status == 'opened')
     return q.all()
Ejemplo n.º 5
0
 def get_taken_calls(self, user_id, start=None,
                     end=None, timestamps=False):
     q = self.query()
     q = q.filter(PhoneCall.received_by_id == user_id)
     if start is not None:
         if timestamps:
             start, end = convert_range_to_datetime(start, end)
         q = self._received_range_filter(q, start, end)
     q = q.filter(TicketCurrentStatus.status != 'closed')
     return q.all()
Ejemplo n.º 6
0
 def get_accessible(self, user_id,
                start=None, end=None, timestamps=False):
     q = self.session.query(CaseCurrentStatus)
     q = q.filter(CaseUser.case_id == CaseCurrentStatus.case_id)
     q = q.filter(CaseUser.user_id == user_id)
     if start is not None:
         if timestamps:
             start, end = convert_range_to_datetime(start, end)
         q = self._range_filter(q, start, end)
     q = q.filter(CaseCurrentStatus.status != 'closed')
     return q.all()
Ejemplo n.º 7
0
 def get_delegated_query(self, user_id,
                         start=None, end=None, timestamps=False):
     q = self.session.query(CaseCurrentStatus)
     q = q.filter_by(changed_by_id=user_id)
     if start is not None:
         if timestamps:
             start, end = convert_range_to_datetime(start, end)
         q = self._range_filter(q, start, end)
     q = q.filter(CaseCurrentStatus.status != 'closed')
     q = q.filter(CaseCurrentStatus.handler_id != user_id)
     return q
Ejemplo n.º 8
0
 def get_delegated_calls(self, user_id, start=None,
                        end=None, timestamps=False):
     q = self.query()
     q = q.filter(PhoneCall.callee_id == user_id)
     if start is not None:
         if timestamps:
             start, end = convert_range_to_datetime(start, end)
         q = self._received_range_filter(q, start, end)
     q = q.filter(TicketCurrentStatus.status == 'pending')
     q = q.filter(TicketCurrentStatus.changed_by_id != user_id)
     return q.all()
Ejemplo n.º 9
0
 def get_current_status_range(self, start, end, timestamps=False):
     if timestamps:
         start, end = convert_range_to_datetime(start, end)
     q = self.session.query(CaseCurrentStatus)
     q = self._range_filter(q, start, end)
     return q.all()    
Ejemplo n.º 10
0
 def get_documents(self, start, end, timestamps=False):
     if timestamps:
         start, end = convert_range_to_datetime(start, end)
     q = self.session.query(ScannedDocument)
     q = self._range_filter(q, start, end)
     return q.all()
Ejemplo n.º 11
0
 def ranged_events(self, start, end, timestamps=False):
     if timestamps:
         start, end = convert_range_to_datetime(start, end)
     q = self.query()
     q = self._range_filter(q, start, end)
     return q.all()