Ejemplo n.º 1
0
 def find_by_day(self, day):
     """Find activities matching a given day.
     Args:
         day(uint): the day to find the activities for
     Returns:
         the activities taking place in the given day."""
     return list(filter(lambda x: x.date.day == day, self.get_all()))
Ejemplo n.º 2
0
 def find_by_phone_number(self,phone_number):
     """Find a person entity in the repository matching a given phone number.
     Args:
         phone_number(str): the phone number of the person to be found
     Returns:
         the person object matching the given phone number.
     """
     return list(filter(lambda x: phone_number in x.phone_number,self.get_all()))
Ejemplo n.º 3
0
 def find_by_name(self,name):
     """Find a person entity in the repository matching a given name.
     Args:
         name(str): the name of the person to be found
     Returns:
         the person object matching the given name.
     """
     return list(filter(lambda x: name.lower() in x.name.lower(),self.get_all()))
Ejemplo n.º 4
0
 def find_by_time(self, time):
     """Find activities matching a given time.
     Args:
         time(_datetime.time): the time in which the activities take place
     Returns:
         the activities matching the given time frame.
     """
     return list(filter(lambda x: x.time == time, self.get_all()))
Ejemplo n.º 5
0
 def find_by_date(self, date):
     """Find activities  matching a given date.
     Args:
         date(_datetime.date): the date on which the activities take
     Returns:
         the activities matching the given date.
     """
     return list(filter(lambda x: x.date == date, self.get_all()))
Ejemplo n.º 6
0
 def statistics_activity_by_week(self, week):
     """Create statistics for participations for a given week."""
     return list(
         filter(
             lambda x: x.activity_id in [
                 e.entity_id
                 for e in self.__activity_controller.find_by_week(week)
             ], self.get_all()))
Ejemplo n.º 7
0
 def statistics_activity_by_day(self, day):
     """Create statistics for an activity that has a given day."""
     return list(
         filter(
             lambda x: x.activity_id in [
                 e.entity_id
                 for e in self.__activity_controller.find_by_day(day)
             ], self.get_all()))
Ejemplo n.º 8
0
 def find_by_activity_description(self, description):
     """Find a participation by the activity description."""
     return list(
         filter(
             lambda x: x.activity_id in [
                 e.entity_id for e in self.__activity_controller.
                 find_by_description(description)
             ], self.get_all()))
Ejemplo n.º 9
0
 def find_by_activity_time(self, time):
     """Find a participation by the activity time."""
     return list(
         filter(
             lambda x: x.activity_id in [
                 e.entity_id
                 for e in self.__activity_controller.find_by_time(time)
             ], self.get_all()))
Ejemplo n.º 10
0
 def find_by_description(self, description):
     """Find activities matching a given description(partial string matching).
     Args:
         description(str): the description of the activities to be found
     Returns:
         the activities matching the given description.
     """
     return list(
         filter(lambda x: description in x.description, self.get_all()))
Ejemplo n.º 11
0
 def get_all_activities(self):
     """Return a dict list with all the activity objects."""
     return map(
         lambda x: self.__activity_controller.find_by_id(x.activity_id),
         list(
             filter(
                 lambda x: x.activity_id in [
                     e.entity_id
                     for e in self.__activity_controller.get_all()
                 ], self.get_all())))
Ejemplo n.º 12
0
 def find_by_week(self, week):
     """Find activities by a given week number.
     Args:
         week(uint): the week to find the activities for
     Returns:
         the activities taking place in the given week.
     """
     return list(
         filter(
             lambda x: x.date >= self.__compute_week_date(week - 1) and x.
             date <= self.__compute_week_date(week), self.get_all()))
Ejemplo n.º 13
0
    def test_filter(self):
        list = [1, 2, 3, 4, 5]
        list = filter(lambda x: x > 2, list)

        self.assertEqual(list, [3, 4, 5], "The list should be [3,4,5]")
Ejemplo n.º 14
0
 def find_by_person_id(self, person_id):
     """Find a participation by the id of the person."""
     return list(filter(lambda x: x.person_id == person_id, self.get_all()))
Ejemplo n.º 15
0
 def find_by_activity_id(self, activity_id):
     """Find a participation by the id of the activity."""
     return list(
         filter(lambda x: x.activity_id == activity_id, self.get_all()))
Ejemplo n.º 16
0
 def statistics_activity_by_person(self, person_id):
     """Create statstics for participations that contain a given person."""
     return list(filter(lambda x: x.person_id == person_id, self.get_all()))