python类Min()的实例源码

services.py 文件源码 项目:dsmr-reader 作者: dennissiemensma 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def range_statistics(start, end):
    """ Returns the statistics (totals) for a target date. Its month will be used. """
    return DayStatistics.objects.filter(day__gte=start, day__lt=end).aggregate(
        total_cost=Sum('total_cost'),
        electricity1=Sum('electricity1'),
        electricity1_cost=Sum('electricity1_cost'),
        electricity1_returned=Sum('electricity1_returned'),
        electricity2=Sum('electricity2'),
        electricity2_cost=Sum('electricity2_cost'),
        electricity2_returned=Sum('electricity2_returned'),
        electricity_merged=Sum(models.F('electricity1') + models.F('electricity2')),
        electricity_cost_merged=Sum(models.F('electricity1_cost') + models.F('electricity2_cost')),
        electricity_returned_merged=Sum(models.F('electricity1_returned') + models.F('electricity2_returned')),
        gas=Sum('gas'),
        gas_cost=Sum('gas_cost'),
        temperature_min=Min('lowest_temperature'),
        temperature_max=Max('highest_temperature'),
        temperature_avg=Avg('average_temperature'),
    )
views.py 文件源码 项目:wifi-attendance 作者: elvinzeng 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def get(self, request):
        if request.user.is_authenticated():
            histories = OnlineHistory.objects.filter(mac=request.user.username)\
                .values('date').annotate(min_time=Min('time'), max_time=Max('time')).order_by("-date")
            return render(request, "index.html", locals())
        else:
            verification_token = str(uuid.uuid4())
            request.session["verification_token"] = verification_token
            return render(request, "authentication.html", locals())
views.py 文件源码 项目:wifi-attendance 作者: elvinzeng 项目源码 文件源码 阅读 35 收藏 0 点赞 0 评论 0
def get(self, request):
        if request.user.has_perm("mobile_scanner.view_staffonlinehistory"):
            histories = OnlineHistory.objects.filter()\
                .values('date', 'user__last_name', 'user__first_name').annotate(min_time=Min('time'), max_time=Max('time')).order_by("-date")
            return render(request, "staff.html", locals())
        else:
            msg = "?????"
            return render(request, "msg.html", locals())
models.py 文件源码 项目:autostew 作者: Autostew 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def get_fastest_laps_by_vehicle(self, vehicle):
        return Lap.objects.filter(
            session__setup_actual__track=self,
            participant__vehicle=vehicle,
            count_this_lap=True,
            participant__is_player=True,
        ).values(
            'participant',
            'participant__member__steam_user__display_name',
            'participant__vehicle__name'
        ).annotate(fastest_lap_time=Min('lap_time')).order_by('fastest_lap_time')
models.py 文件源码 项目:autostew 作者: Autostew 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def get_fastest_laps_by_vehicle_class(self, vehicle_class):
        return Lap.objects.filter(
            session__setup_actual__track=self,
            participant__vehicle__vehicle_class=vehicle_class,
            count_this_lap=True,
            participant__is_player=True,
        ).values(
            'participant__name',
            'participant__vehicle__name'
        ).annotate(fastest_lap_time=Min('lap_time')).order_by('fastest_lap_time')
models.py 文件源码 项目:autostew 作者: Autostew 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def _best_in_stage_evaluation(self, field_name):
        return getattr(self, field_name) <= self.participant.lap_set.filter(
            **{
                '{}__gt'.format(field_name): 0,
                'session_stage': self.session_stage
            }
        ).aggregate(Min(field_name))['{}__min'.format(field_name)]
models.py 文件源码 项目:ODM2WebSDL 作者: ODM2 项目源码 文件源码 阅读 42 收藏 0 点赞 0 评论 0
def deployment_date(self):
        min_datetime = self.sensors.aggregate(first_light=Min('activation_date'))
        return min_datetime['first_light']
models.py 文件源码 项目:ODM2WebSDL 作者: ODM2 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def deployment_date(self):
        sampling_feature = self.sampling_feature
        min_datetime = sampling_feature.feature_actions.aggregate(first_light=Min('results__valid_datetime'))
        return min_datetime['first_light']
models.py 文件源码 项目:tunga-api 作者: tunga-io 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def started_at(self):
        return self.subtask_participants_inclusive_filter.filter(status=STATUS_ACCEPTED).aggregate(
            start_date=Min('activated_at'))['start_date']


问题


面经


文章

微信
公众号

扫码关注公众号