Exemplo n.º 1
0
    def get_static_from_tour_guide_popularity(start_date, end_date):
        """
        Return an descending ordered list from tourguide's tours popularity between dates.

        You can find an example to call this method in testdatabase.py file.
        :param start_date: String that represent a date like this: "2015-09-01"
        :param end_date: same as start_date
        :return:
        """
        list_of_tours = TourDAO.get_list_of_tours_between_dates(
            start_date, end_date)

        d = dict()
        for tour in list_of_tours:
            if tour.tour_guide_id in d:
                d[tour.
                  tour_guide_id] += RegistrationDAO.get_registration_count_by_tour_id(
                      tour.id)
            else:
                d[tour.
                  tour_guide_id] = RegistrationDAO.get_registration_count_by_tour_id(
                      tour.id)

        return_list = []
        for key, value in d.items():
            return_list.append((UserDAO.get_user_by_id(key).fullname, value))

        return_list = sorted(return_list,
                             key=StatisticDAO.get_key,
                             reverse=True)

        return return_list
    def get_static_from_tour_guide_popularity(start_date, end_date):
        """
        Return an descending ordered list from tourguide's tours popularity between dates.

        You can find an example to call this method in testdatabase.py file.
        :param start_date: String that represent a date like this: "2015-09-01"
        :param end_date: same as start_date
        :return:
        """
        list_of_tours = TourDAO.get_list_of_tours_between_dates(start_date, end_date)

        d = dict()
        for tour in list_of_tours:
            if tour.tour_guide_id in d:
                d[tour.tour_guide_id] += RegistrationDAO.get_registration_count_by_tour_id(tour.id)
            else:
                d[tour.tour_guide_id] = RegistrationDAO.get_registration_count_by_tour_id(tour.id)

        return_list = []
        for key, value in d.items():
            return_list.append((UserDAO.get_user_by_id(key).fullname, value))

        return_list = sorted(return_list, key=StatisticDAO.get_key, reverse=True)

        return return_list
Exemplo n.º 3
0
    def get_tours(start_date, end_date):
        """
        Return a list of tuple.

        Tuple contains a name and number of registered member. The return list is ordered.
        You can find an example to call this method in testdatabase.py file.
        :param start_date: String that represent a date like this: "2015-09-01"
        :param end_date: same as start_date
        :return:
        """
        list_of_tours = TourDAO.get_id_list_of_tours_by_date(
            start_date, end_date)

        d = dict()
        for name, id in list_of_tours:
            d[id] = RegistrationDAO.get_registration_count_by_tour_id(id)

        return_list = []
        for name, id in list_of_tours:
            return_list.append((name, d[id]))

        return_list = sorted(return_list,
                             key=StatisticDAO.get_key,
                             reverse=True)

        return return_list
    def get_tours(start_date, end_date):
        """
        Return a list of tuple.

        Tuple contains a name and number of registered member. The return list is ordered.
        You can find an example to call this method in testdatabase.py file.
        :param start_date: String that represent a date like this: "2015-09-01"
        :param end_date: same as start_date
        :return:
        """
        list_of_tours = TourDAO.get_id_list_of_tours_by_date(start_date, end_date)

        d = dict()
        for name, id in list_of_tours:
            d[id] = RegistrationDAO.get_registration_count_by_tour_id(id)

        return_list = []
        for name, id in list_of_tours:
            return_list.append((name, d[id]))

        return_list = sorted(return_list, key=StatisticDAO.get_key, reverse=True)

        return return_list
Exemplo n.º 5
0
 def test_setPrice(self):
     t = Tour("ABC", 3, 2)
     t.id = 1
     t.price = 3000
     l = [t]
     self.assertEquals(TourDAO.set_prices(l), True)
Exemplo n.º 6
0
 def test_delete_tour(self):
     print(TourDAO.delete_tour(2))
     self.assertEquals(True, True)
Exemplo n.º 7
0
 def test_delay_tour(self):
     print(TourDAO.delay_tour(1, "2016-09-01 00:00", "2016-10-01 00:00"))
     self.assertEquals(True, True)
Exemplo n.º 8
0
 def test_get_list_of_Tour(self):
     l = TourDAO.get_id_list_of_tours_by_date("2015-12-01", "2016-04-01")
     for x in l:
         print(x)
     self.assertEquals(True, True)
Exemplo n.º 9
0
 def test_setPrice(self):
     t = Tour("ABC", 3, 2)
     t.id = 1
     t.price = 3000
     l = [t]
     self.assertEquals(TourDAO.set_prices(l), True)
Exemplo n.º 10
0
 def test_delete_tour(self):
     print(TourDAO.delete_tour(2))
     self.assertEquals(True, True)
Exemplo n.º 11
0
 def test_delay_tour(self):
     print(TourDAO.delay_tour(1, "2016-09-01 00:00", "2016-10-01 00:00"))
     self.assertEquals(True, True)
Exemplo n.º 12
0
 def test_get_list_of_Tour(self):
     l = TourDAO.get_id_list_of_tours_by_date("2015-12-01", "2016-04-01")
     for x in l:
         print(x)
     self.assertEquals(True, True)