コード例 #1
0
   # - Prepare the Petrus
   # ----------------------------------------------------------------
   username = '******'
   db.create_user( username )
   userID = db.get_user_id( username )
   
   # ----------------------------------------------------------------
   # - Compute its mitteltip, one for each station. 
   # ----------------------------------------------------------------
   for city in cities:
   
      print '\n  * Compute the %s for city %s (ID: %d)' % (username,city['name'], city['ID']) 
   
      # - Returns list object containing two dicts 
      #   where all the bets are in.
      bet = mitteltip.mitteltip(db,'all',False,city,tdate)
 
      # - If bet is False, continue
      if bet == False: continue
   
      # -------------------------------------------------------------
      # - Inserting into database now
      # -------------------------------------------------------------
      print '    Inserting data into database now'
      for day in range(1,3):
         for k in bet[day-1].keys():
            paramID = db.get_parameter_id(k)
            db.upsert_bet_data(userID,city['ID'],paramID,tdate,day,bet[day-1][k])
   
   db.commit()
   db.close()
コード例 #2
0
                # - I do not have the judgingclass before the rule changes in
                #   2002 (2002-12-06) and therefore it does not make any sense
                #   to compute MeanBets for that time period (becuase we can
                #   never compute the corresponding points). Skip.
                # ----------------------------------------------------------------
                if tdate < 12027:
                    from judgingclass20021206 import judging
                    print '[!] I dont know the rules to compute points before 2002-12-06'
                    print '    Therefore it makes no sense to compute MeanBets. Skip.'
                    continue

                # -------------------------------------------------------------
                # - List element to store the two dict dbects
                #   containing the bets for Petrus
                # -------------------------------------------------------------
                bet = mitteltip.mitteltip(db, 'group', groupID, city, tdate)

                # -------------------------------------------------------------
                # - If at least one query returnd no data, mitteltip returns
                #   False. We cannot compute the Mitteltip. Message and
                #   continue.
                # -------------------------------------------------------------
                if not bet:
                    print '[!] At least one parameter returned no data. Skip!!'
                    continue

                # -------------------------------------------------------------
                # - Inserting into database now
                # -------------------------------------------------------------
                print '    Inserting data into database now'
                for day in range(1, 3):
コード例 #3
0
                        value = db.get_bet_data('user', userID, city['ID'],
                                                paramID, tdate, day + 1)
                        coef = moses[param][user]
                        # - If value is False the player did not submit his/her bet!

                        if value == False: continue
                        else:
                            bet[day][param] = np.append(
                                bet[day][param],
                                np.repeat(value, int(float(coef) * 100000)))
                    #   Use Petrus fallback.
                    if len(bet[day][param]) == 0:
                        bet[day][param] = db.get_bet_data(
                            'user', petrus_userID, city['ID'], paramID, tdate,
                            day + 1)
            bet = mitteltip.mitteltip(db, 'moses', False, city, tdate, bet)

            # - If bet is False, continue
            if bet == False: continue

            # -------------------------------------------------------------
            # - Inserting into database now
            # -------------------------------------------------------------
            print('    Inserting data into database now')
            for day in range(1, 3):
                for k in params:
                    paramID = db.get_parameter_id(k)
                    db.upsert_bet_data(moses_userID, city['ID'], paramID,
                                       tdate, day, bet[day - 1][k])

    db.commit()
コード例 #4
0
            if check:
                print '    Date is \'locked\' (datelock). Dont execute, skip.'
                continue

            # ----------------------------------------------------------------
            # - Compute mitteltip mean of all stations of each city...
            # ----------------------------------------------------------------
            for city in cities:
                print '\n  * Compute the %s for city %s (ID: %d)' % (
                    username, city['name'], city['ID'])

                # - bit hacky: go j days back in mitteltip function and get obs
                #   instead of user bets like in Petrus. typ='persistenz' for db
                #   idea: we could also take thursday's obs for saturday and
                #   fridays tip for sunday, or even saturday's for sunday...
                bet = mitteltip.mitteltip(db, 'persistenz', False, city,
                                          tdate - j)

                # - If bet is False, continue
                if bet == False:
                    print "NO BETDATA"
                    continue

                # - Save into database. Note: we have loaded the persistence
                #   data from the tournament (e.g. Friday)
                #   but have to store for two days (saturday, sunday). Therefore
                #   there is the day-loop here.
                for day in range(1, 3):
                    print "    Insert %s bets into database for day %d" % (i,
                                                                           day)
                    for k in bet[day - 1].keys():
                        paramID = db.get_parameter_id(k)