Exemple #1
0
  def get(self):

        db_events_query = DBEvent.query()
        db_events_query = db_events_query.order(DBEvent.date)

        mined_events_query = DBAutoMined.query()
        mined_events_query = mined_events_query.order(DBAutoMined.date)
        mined_events_query_results = mined_events_query.filter(DBAutoMined.location=='Conga Room').fetch()

        #print 'RESULTS:',len(mined_events_query_results)

        for entity in mined_events_query_results:
            #print 'Pre-Processing',entity.name,entity.location,entity.date

            db_events_query_results = db_events_query.filter(DBEvent.name==entity.name).fetch()

            # Does the Event already exists in the DB ?

            # Yes: Update it
            if len(db_events_query_results):
                print 'Updating',entity.name
                for event in db_events_query_results:
                    event.cover = float(entity.price)
                    event.date  = entity.date
                    event.put()
            else:
                # No: Create it
                if (not entity.promoted) and entity.promote_to_db:
                    #print 'Processing',entity.name,entity.location,entity.date
                    print 'Creating',entity.name
                    newEvent = DBEvent(name  = entity.name,
                         venue        = entity.location,
                         date         = entity.date,
                         type         = 'event',
                         open_days    = [],
                         cover        = float(entity.price),
                         rating       = 1.5,
                         description  = 'Concert at the Conga Room',
                         address      = '800 W. Olympic Blvd, Los Angeles, CA 90015',
                         gps_pos_lat  = 34.0449817,
                         gps_pos_lon  = -118.3276732,
                         phone        = '2137450162',
                         thumbnail_image_locator = '/defaults/thumbnails/event.png',
                         images_locators         = [],
                         videos_locators         = [])

                    errorWhileWritingEvent = False
                    try:
                        newEvent.put()
                    except:
                        errorWhileWritingEvent = True
                        print 'Error while creating DbEvent for :',entity.name,entity.location,entity.date

                    if not errorWhileWritingEvent:
                        entity.promoted = True
                        entity.put()
Exemple #2
0
  def get(self):
        #models.DBAutoMined.query(name='Conga Room')

        cr = EventsUpdater()
        events = cr.getEventsFor('CongaRoom')

        for event in events:
            # Builds datetime from String
            atime     = time.strptime(event.date+' '+event.time,"%Y-%m-%d %H:%M:%S")
            adatetime = datetime.datetime.fromtimestamp(mktime(atime))

            entity = DBAutoMined.query(DBAutoMined.mine_id==hash(event.date+event.title))

            if not entity.get():
                #event.debug()
                autoMinedEvent = DBAutoMined(mine_id  = hash(event.date+event.title),
                                                    name     = event.title,
                                                    date     = adatetime,
                                                    type     = 'Concert',
                                                    price    = event.price,
                                                    location = event.location,
                                                    promoted = False,
                                                    promote_to_db = True)
                autoMinedEvent.put()