mast/queries.py
def _get_total_distance_by_user(self, user_id: int, activity_types: list):
        """
        Returns the total distance taken by a specified user in a specified types of activity.
        :param user_id: ID of user.
        :param activity_types: Types of activities we want to sum to total distance.
        :returns: The total distance in kilometres.
        """
        return db.session.query(func.sum(Activity.distance)). \
            filter(Activity.user_id == user_id,
                   func.date(Activity.datetime) >= self.SEASON.start_date,
                   func.date(Activity.datetime) <= self.SEASON.end_date,
                   Activity.type.in_(activity_types)). \
            scalar()

        Returns the total distance taken by a specified user in a specified types of activity.
        :param user_id: ID of user.
        :param activity_types: Types of activities we want to sum to total distance.
        :returns: The total distance in kilometres.
        
Returns the total distance taken by a specified user in a specified types of activity.
Returns the total distance taken by a specified user in a specified types of activity .
def _get_total_distance_by_user(self, user_id: int, activity_types: list):
        return db.session.query(func.sum(Activity.distance)). \
            filter(Activity.user_id == user_id,
                   func.date(Activity.datetime) >= self.SEASON.start_date,
                   func.date(Activity.datetime) <= self.SEASON.end_date,
                   Activity.type.in_(activity_types)). \
            scalar()
def _get_total_distance_by_user ( self , user_id : int , activity_types : list ) : return db . session . query ( func . sum ( Activity . distance ) ) . filter ( Activity . user_id == user_id , func . date ( Activity . datetime ) >= self . SEASON . start_date , func . date ( Activity . datetime ) <= self . SEASON . end_date , Activity . type . in_ ( activity_types ) ) . scalar ( )
Returns the total distance taken by a specified user in a specified types of activity.
Returns the total distance taken by a specified user in a specified types of activity .
"""
        Returns the total distance taken by a specified user in a specified types of activity.
        :param user_id: ID of user.
        :param activity_types: Types of activities we want to sum to total distance.
        :returns: The total distance in kilometres.
        """
The total distance in kilometres.
The total distance in kilometres .
self
user_id
int
ID of user.
ID of user .
activity_types
list
Types of activities we want to sum to total distance.
Types of activities we want to sum to total distance .