Esempio n. 1
0
 def overview(self, request):
     content = []
     for org in self.queryset:
         org_data = {}
         org_data['org_id'] = org.org_id
         org_data['org_name'] = org.org_name
         org_data['user_count'] = models.MisUmuser.objects.filter(org_id=org.org_id).count()
         tp = TimePeriod()
         start_time, end_time = tp.visit('month')
         org_data['month_count'] = models.CmUserInstaMapping.objects.filter(is_vm=1, project_id=org.org_id,
                                                                            created_at__lte=end_time,
                                                                            created_at__gte=start_time).count()
         start_time, end_time = tp.visit('quarter')
         org_data['quarter_count'] = models.CmUserInstaMapping.objects.filter(is_vm=1, project_id=org.org_id,
                                                                              created_at__lte=end_time,
                                                                              created_at__gte=start_time).count()
         start_time, end_time = tp.visit('year')
         org_data['year_count'] = models.CmUserInstaMapping.objects.filter(is_vm=1, project_id=org.org_id,
                                                                           created_at__lte=end_time,
                                                                           created_at__gte=start_time).count()
         start_time, end_time = tp.visit('all')
         org_data['total_count'] = models.CmUserInstaMapping.objects.filter(is_vm=1, project_id=org.org_id,
                                                                            created_at__lte=end_time,
                                                                            created_at__gte=start_time).count()
         org_data['ticket_count'] = models.WorkOrder.objects.filter(org_id=org.org_id).count()
         content.append(org_data)
     return Response(content)
Esempio n. 2
0
 def user_overview(self, request, org_id):
     content = []
     user_set = models.MisUmuser.objects.filter(org_id=org_id)
     for user in user_set:
         user_data = {}
         user_data['user_id'] = user.user_id
         user_data['user_name'] = user.user_name
         tp = TimePeriod()
         start_time, end_time = tp.visit('month')
         user_data['month_count'] = models.CmUserInstaMapping.objects.filter(is_vm=1, user_id=user.user_id,
                                                                             created_at__lte=end_time,
                                                                             created_at__gte=start_time).count()
         start_time, end_time = tp.visit('quarter')
         user_data['quarter_count'] = models.CmUserInstaMapping.objects.filter(is_vm=1, user_id=user.user_id,
                                                                               created_at__lte=end_time,
                                                                               created_at__gte=start_time).count()
         start_time, end_time = tp.visit('year')
         user_data['year_count'] = models.CmUserInstaMapping.objects.filter(is_vm=1, user_id=user.user_id,
                                                                            created_at__lte=end_time,
                                                                            created_at__gte=start_time).count()
         start_time, end_time = tp.visit('all')
         user_data['total_count'] = models.CmUserInstaMapping.objects.filter(is_vm=1, user_id=user.user_id,
                                                                             created_at__lte=end_time,
                                                                             created_at__gte=start_time).count()
         user_data['ticket_count'] = models.WorkOrder.objects.filter(user_id=user.user_id).count()
         content.append(user_data)
     return Response(content)
Esempio n. 3
0
 def count(self, request):
     try:
         content = {}
         period = request.GET.get('period') or 'all'
         tp = TimePeriod()
         start_time, end_time = tp.visit(period)
         content['work_order_count'] = models.WorkOrder.objects.filter(commit_time__lte=end_time,
                                                                       commit_time__gte=start_time).count()
         return Response(content)
     except:
         raise Http404
Esempio n. 4
0
 def count(self, request):
     try:
         content = {}
         period = request.GET.get('period') or 'all'
         tp = TimePeriod()
         start_time, end_time = tp.visit(period)
         content['instance_count'] = models.CmUserInstaMapping.objects.filter(is_vm=1, created_at__lte=end_time,
                                                                              created_at__gte=start_time).count()
         return Response(content)
     except:
         raise Http404
Esempio n. 5
0
 def list(self, request):
     content = {}
     content['user_count'] = models.MisUmuser.objects.all().count()
     content['depart_count'] = models.MisUmorg.objects.all().count()
     content['host_count'] = self.queryset.count()
     period = request.GET.get('period') or 'all'
     tp = TimePeriod()
     start_time, end_time = tp.visit(period)
     content['instance_count'] = models.CmUserInstaMapping.objects.filter(is_vm=1, created_at__lte=end_time,
                                                                          created_at__gte=start_time).count()
     content['ticket_count'] = models.WorkOrder.objects.filter(commit_time__lte=end_time,
                                                               commit_time__gte=start_time).count()
     content['storage_count'] = models.Device.objects.filter(online_time__lte=end_time,
                                                             online_time__gte=start_time,classification=2).count()
     content['network_count'] = models.Device.objects.filter(online_time__lte=end_time,
                                                             online_time__gte=start_time,classification=3).count()
     return Response(content)
Esempio n. 6
0
def extract_TimePeriod(dss):
    # returns an instance of utils.TimePeriod
    tp = dss.find("./" + GML_NS + "TimePeriod")
    if None == tp: return None
    begin_pos = tp.find("./" + GML_NS + "beginPosition")
    end_pos = tp.find("./" + GML_NS + "endPosition")
    if None == begin_pos or None == end_pos: return None
    return TimePeriod(begin_pos.text, end_pos.text)
Esempio n. 7
0
 def overview(self, request):
     content = []
     for user in self.queryset:
         user_data = {}
         user_data['user_name'] = user.user_name
         tp = TimePeriod()
         start_time, end_time = tp.visit('month')
         user_data['month_count'] = models.CmUserInstaMapping.objects.filter(is_vm=1, user_id=user.user_id,
                                                                             created_at__lte=end_time,
                                                                             created_at__gte=start_time).count()
         start_time, end_time = tp.visit('quarter')
         user_data['quarter_count'] = models.CmUserInstaMapping.objects.filter(is_vm=1, user_id=user.user_id,
                                                                               created_at__lte=end_time,
                                                                               created_at__gte=start_time).count()
         start_time, end_time = tp.visit('year')
         user_data['year_count'] = models.CmUserInstaMapping.objects.filter(is_vm=1, user_id=user.user_id,
                                                                            created_at__lte=end_time,
                                                                            created_at__gte=start_time).count()
         start_time, end_time = tp.visit('all')
         user_data['total_count'] = models.CmUserInstaMapping.objects.filter(is_vm=1, user_id=user.user_id,
                                                                             created_at__lte=end_time,
                                                                             created_at__gte=start_time).count()
         content.append(user_data)
     return Response(content)