Exemplo n.º 1
0
    def create_test_data(cls, cinema_num=10, hall_num=10, play_num=10):
        HALL_SEATS_NUM = 25
        start_time = time.time()
        from tigereye.models.hall import Hall
        from tigereye.models.movie import Movie
        from tigereye.models.play import Play
        from tigereye.models.seat import Seat, PlaySeat
        from tigereye.models.order import Order
        f = faker.Faker('zh_CN')
        screen_types = ['普通', 'IMAX']
        audio_types = ['普通', '杜比环绕']
        cinemas = []
        for i in range(1, cinema_num + 1):
            cinema = Cinema()
            cinema.cid = i
            cinema.name = '%s影城' % f.name()
            cinema.address = f.address()
            cinema.status = 1
            cinema.put()
            cinemas.append(cinema)
        Cinema.commit()

        halls = []
        plays = []
        seats = []
        for cinema in cinemas:
            for n in range(1, hall_num + 1):
                hall = Hall()
                hall.cid = cinema.cid
                hall.name = '%s号厅' % n
                hall.screen_type = random.choice(screen_types)
                hall.audio_type = random.choice(audio_types)
                hall.seats_num = HALL_SEATS_NUM
                hall.status = 1
                hall.put()
                halls.append(hall)
            Hall.commit()

        for hall in halls:
            hall.seats = []
            for s in range(1, hall.seats_num + 1):
                seat = Seat()
                seat.cid = hall.cid
                seat.hid = hall.hid
                seat.x = s % 5 or 5
                seat.y = math.ceil(s / 5)
                seat.row = seat.x
                seat.column = seat.y
                seat.seat_type = 1
                seat.put()
                hall.seats.append(seat)
            Seat.commit()

            for p in range(1, play_num + 1):
                play = Play()
                play.cid = cinema.cid
                play.hid = hall.hid
                play.mid = p
                play.start_time = datetime.now()
                play.duration = 3600
                play.price_type = 1
                play.price = 7000
                play.market_price = 5000
                play.lowest_price = 3000
                play.status = 1
                play.put()
                play.hall = hall
                plays.append(play)
            Play.commit()

        for play in plays:
            for seat in play.hall.seats:
                ps = PlaySeat()
                ps.pid = play.pid
                ps.copy(seat)
                ps.put()
            PlaySeat.commit()
        current_app.logger.info('create test data done! cost %.2f seconds' %
                                (time.time() - start_time))
Exemplo n.º 2
0
    def create_test_data(cls,cinema_num = 3,hall_num = 3,play_num = 10):
            import  time


            from tigereye.models.hall import Hall
            from tigereye.models.seat import Seat,PlaySeat,SeatType
            from tigereye.models.movie import Movie
            from tigereye.models.cinema import Cinema
            from tigereye.models.play import Play
            from faker import Faker
            import math
            from datetime import datetime
            start_time = time.time()
            HALL_SEATS_NUM = 25
            faker = Faker('zh_CN')
            cinemas = []
            for i in range(1,cinema_num+1):
                cinema = Cinema()
                cinema.name = '%s影城' % faker.name()
                cinema.address = faker.address()
                cinema.status = 1
                cinema.put()
                cinemas.append(cinema)
            Cinema.commit()
            halls = []
            plays = []

            for cinema in cinemas:
                for n in range(1,hall_num+1):
                    hall = Hall()
                    hall.cid = cinema.cid
                    hall.name = '%s 号厅' % n
                    hall.screen_type = "IMAX"
                    hall.audio_type = '杜比环绕'
                    hall.seats_num = HALL_SEATS_NUM
                    hall.status = 1
                    hall.put()
                    halls.append(hall)
                Hall.commit()

            for hall in halls:
                hall.seats = []


                for x in range(1,HALL_SEATS_NUM+1):
                    seat = Seat()
                    seat.cid = hall.cid
                    seat.hid = hall.hid
                    seat.x = x % 5 or 5
                    seat.y = math.ceil(x / 5)
                    seat.row = '%s 排' % seat.x
                    seat.column = '%s 列' % seat.y
                    seat.seat_type = SeatType.single.value

                    seat.status = SeatStatus.ok.value
                    seat.put()
                    hall.seats.append(seat)
                Seat.commit()



                for p in range(1,play_num+1):
                     play = Play()
                     play.cid = hall.cid
                     play.hid = hall.hid
                     play.mid = p
                     play.start_time = datetime.now()
                     play.duration = 3600
                     play.price_type = 1
                     play.price = 70000
                     play.market_price = 5000
                     play.lowest_price = 3000
                     play.status = 1
                     play.put()
                     play.hall = hall
                     plays.append(play)
                Play.commit()
            for play in plays:


                for seat in play.hall.seats:
                     ps = PlaySeat()
                     ps.pid = play.pid
                     ps.copy(seat)
                     ps.put()


                PlaySeat.commit()


            for i in range(10):
                m = Movie()
                m.name = '电影名称 %s' % (i +1)
                m.language = '英文'
                m.subtitle = '中文'
                m.mode = '数字'
                m.vision = '3D'
                m.screen_size = 'IMAX'
                m.introduction = '哈哈哈'
                m.status = 1
                m.save()
            print('create test data done! cost %s seconds' % (time.time() - start_time))
Exemplo n.º 3
0
    def create_test_data(cls, cinema_num=10, hall_num=10, play_num=10):
        from tigereye.models.hall import Hall
        from tigereye.models.movie import Movie
        from tigereye.models.order import Order
        from tigereye.models.seat import Seat, PlaySeat
        from tigereye.models.play import Play

        time1 = time.time()

        f = faker.Faker('zh_CN')
        screen_types = ['普通', 'IMAX']
        audio_types = ['普通', '杜比环绕']
        cm_name = ['影院', '影城', '国际影城', '国际影院']
        for i in range(1, cinema_num + 1):
            cinema = Cinema()
            cinema.cid = i
            cinema.name = f.company()[:-6] + random.choice(cm_name)
            cinema.address = f.address()
            cinema.status = 1
            print(cinema.name)
            cinema.save()

            for n in range(1, hall_num + 1):
                hall = Hall()
                hall.cid = cinema.cid
                hall.name = '%s号厅' % n
                hall.screen_type = random.choice(screen_types)
                hall.audio_type = random.choice(audio_types)
                hall.seats_num = 25
                hall.status = 1
                hall.save()

                seats = []
                for s in range(1, hall.seats_num + 1):
                    seat = Seat()
                    seat.cid = cinema.cid
                    seat.hid = hall.hid
                    seat.x = s % 5 or 5
                    seat.y = ceil(s / 5)
                    seat.row = seat.x
                    seat.column = seat.y
                    seat.seat_type = 1
                    seat.put()
                    seats.append(seat)
                Seat.commit()

                for p in range(1, play_num + 1):
                    play = Play()
                    play.cid = cinema.cid
                    play.hid = hall.hid
                    play.mid = p
                    play.start_time = datetime.now()
                    play.duration = 3600
                    play.price_type = 1
                    play.price = 7000
                    play.market_price = 5000
                    play.lowest_price = 3000
                    play.status = 1
                    play.save()

                    for seat in seats:
                        ps = PlaySeat()
                        ps.pid = play.pid
                        ps.copy(seat)
                        ps.put()
                    PlaySeat.commit()
        current_app.logger.info('create test data done! %.2f s' %
                                (time.time() - time1))
Exemplo n.º 4
0
    def create_test_data(cls, cinema_num=10, hall_num=10, play_num=10):
        # from tigereye.models.cinerma import Cinema
        from tigereye.models.hall import Hall
        from tigereye.models.movie import Movie
        from tigereye.models.seat import Seat, PlaySeat
        from tigereye.models.play import Play
        from tigereye.models.order import Order
        f = faker.Faker('zh_CN')
        screen_types = ['普通', 'IMAX']
        audio_types = ['普通', '杜比环绕']

        cinemas = []
        for i in range(1, cinema_num + 1):
            cinema = Cinema()
            cinema.cid = i
            cinema.name = '%s影城' % f.name()
            cinema.address = f.address()
            cinema.status = 1
            # cinema.save()
            cinema.put()
            cinemas.append(cinema)
        Cinema.commit()

        halls = []
        for cinema in cinemas:
            for n in range(1, hall_num + 1):
                hall = Hall()
                hall.cid = cinema.cid
                hall.name = '%s号厅' % n
                hall.screen_type = random.choice(screen_types)
                hall.audio_type = random.choice(audio_types)
                hall.seats_num = 25
                hall.status = 1
                hall.put()
                halls.append(hall)

            Hall.commit()

            plays = []
            for hall in halls:
                hall.seats = []
                for s in range(1, hall.seats_num + 1):
                    seat = Seat()
                    seat.cid = cinema.cid
                    seat.hid = hall.hid
                    seat.x = s % 5 % 5
                    seat.y = ceil(s / 5)
                    seat.row = seat.x
                    seat.column = seat.y
                    seat.seat_type = 1
                    seat.put()
                    hall.seats.append(seat)
                Seat.commit()

                for p in range(1, play_num + 1):
                    play = Play()
                    playcid = cinema.cid
                    play.hid = hall.hid
                    play.mid = p
                    play.start_time = datetime.now()
                    play.duration = 3600
                    play.price_type = 1
                    play.price = 7000
                    play.market_price = 5000

            for n in range(1, hall_num + 1):
                hall = Hall()
                hall.cid = cinema.cid
                hall.name = '%s号厅' % n
                hall.screen_type = random.choice(screen_types)
                hall.audio_type = random.choice(audio_types)
                hall.seats_num = 25
                # hall.seats = ''
                hall.status = 1
                hall.save()

                seats = []
                for s in range(1, hall.seats_num + 1):
                    seat = Seat()
                    seat.cid = cinema.cid
                    seat.hid = hall.hid
                    seat.x = s % 5 or 5
                    seat.y = ceil(s / 5)
                    seat.row = seat.x
                    seat.column = seat.y
                    seat.seat_type = 1
                    seat.put()
                    seats.append(seat)
                Seat.commit()

                for p in range(1, play_num + 1):
                    play = Play()
                    play.cid = cinema.cid
                    play.hid = hall.hid
                    play.mid = p
                    play.start_time = datetime.now()
                    play.duration = 3600
                    play.price_type = 1
                    play.price = 7000
                    play.market_price = 5000
                    play.lowest_price = 3000
                    play.status = 1
                    play.save()

                    for seat in seats:
                        ps = PlaySeat()
                        ps.pid = play.pid
                        ps.copy(seat)
                        ps.put()
                    PlaySeat.commit()
Exemplo n.º 5
0
    def create_test_data(cls, cinema_num=10, hall_num=10, play_num=10):
        start_time = time.time()
        from tigereye.models.seat import Seat, PlaySeat
        from tigereye.models.play import Play
        from tigereye.models.hall import Hall
        f = faker.Faker("zh_CN")
        screen_types = ["普通", "IMAX"]
        audio_types = ["普通", "杜比音效"]

        cinemas = []
        for i in range(1, cinema_num + 1):
            cinema = Cinema()
            cinema.cid = i
            cinema.name = "%s影院" % f.name()
            cinema.address = f.address()
            cinema.status = 1
            cinema.put()
            cinemas.append(cinema)
        Cinema.commit()

        halls = []
        for cinema in cinemas:
            for n in range(1, hall_num + 1):
                hall = Hall()
                hall.cid = cinema.cid
                hall.name = "%s号厅" % n
                hall.screen_type = random.choice(screen_types)
                hall.audio_type = random.choice(audio_types)
                hall.seats_num = 25
                hall.status = 1
                hall.put()
                halls.append(hall)
        Hall.commit()

        plays = []
        for hall in halls:
            hall.seats = []
            for s in range(1, hall.seats_num + 1):
                seat = Seat()
                seat.cid = hall.cid
                seat.hid = hall.hid
                seat.x = s % 5 or 5
                seat.y = ceil(s / 5)
                seat.row = seat.x
                seat.column = seat.y
                seat.seat_type = 1
                seat.put()
                hall.seats.append(seat)
            Seat.commit()

            for p in range(1, play_num + 1):
                play = Play()
                play.cid = cinema.cid
                play.hid = hall.hid
                play.mid = p
                play.start_time = datetime.now()
                play.duration = 3600
                play.price_type = 1
                play.price = 7000
                play.market_price = 5000
                play.lowest_price = 3000
                play.status = 1
                play.hall = hall
                play.put()
                plays.append(play)
            Play.commit()

        for play in plays:
            for seat in play.hall.seats:
                ps = PlaySeat()
                ps.pid = play.pid
                ps.copy(seat)
                ps.put()
            PlaySeat.commit()
        current_app.logger.info("screate test data done: %f" %
                                (time.time() - start_time))