当前位置: 首页>>代码示例>>Python>>正文


Python Client.get_segment_leaderboard方法代码示例

本文整理汇总了Python中stravalib.client.Client.get_segment_leaderboard方法的典型用法代码示例。如果您正苦于以下问题:Python Client.get_segment_leaderboard方法的具体用法?Python Client.get_segment_leaderboard怎么用?Python Client.get_segment_leaderboard使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在stravalib.client.Client的用法示例。


在下文中一共展示了Client.get_segment_leaderboard方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from stravalib.client import Client [as 别名]
# 或者: from stravalib.client.Client import get_segment_leaderboard [as 别名]
def main():
    reload(sys)  
    sys.setdefaultencoding('utf8')

   
        
    client = Client(access_token='76824abf6abf903eb3d8b0bde83625135c0be0ec')
    athlete = client.get_athlete()
    print("Hello, {}. I know your email is {}".format(athlete.firstname, athlete.email))
    josh_friends = client.get_athlete_friends(5991862)
    print "Starting...."        
    leaderboard = client.get_segment_leaderboard(2658830,following=True)
    print leaderboard[0].athlete_name

    friend_colour_dict = {}
    friend_colour_file = open('friend_colour.csv')
    colourreader = UnicodeDictReader(friend_colour_file)
    for line in colourreader:
        friend_colour_dict[line["name"]] = line["colour"]

    for x in friend_colour_dict:
        print str(x).encode("utf8")
开发者ID:Josh2K,项目名称:Josh2K.github.io,代码行数:24,代码来源:matwork.py

示例2: str

# 需要导入模块: from stravalib.client import Client [as 别名]
# 或者: from stravalib.client.Client import get_segment_leaderboard [as 别名]
    if "Not Found" in e.message:
      cl.sql('DELETE FROM wbstrava WHERE segment_id= ' + str(id))
      print("Deleted Strava ID: {}".format(id))
    else:
      print("Something's wrong with Strava ID: {}".format(id))

## get list of segments already in CartoDB
queryResult = cl.sql('select segment_id from wbstrava')
currentSegments = [x['segment_id'] for x in queryResult['rows']]

now = datetime.datetime.now()
weekAgo = now + datetime.timedelta(days=-7)
for segment in currentSegments:
  weekEfforts = client.get_segment_efforts(segment, start_date_local=weekAgo, end_date_local=now)
  weekEffortsTimes = [i.moving_time.seconds for i in weekEfforts]
  try:
    leaderboard = client.get_segment_leaderboard(segment, top_results_limit=100)
    leaderboardTimes = [x.moving_time.seconds for x in leaderboard if x.rank <= 100]
#    print('Updated {} with {} efforts and {} leaderboard entries'.format(segment, len(weekEffortsTimes), leaderboard.effort_count))
  except:
#    cl.sql('DELETE FROM wbstrava WHERE segment_id=' + str(segment))
#    print('Deleted: {}'.format(client.get_segment(segment).name))
    print('Couldn\'t update: {}'.format(client.get_segment(segment).name))
  if len(weekEffortsTimes) and len(leaderboardTimes):
    segmentMean = np.divide(np.mean(leaderboardTimes), np.mean(weekEffortsTimes)).astype('str')
  else:
    segmentMean = '0'
  cl.sql('UPDATE wbstrava SET ratio = ' + segmentMean + ' WHERE segment_id=' + str(segment))
  cl.sql('UPDATE wbstrava SET count = ' + str(len(weekEffortsTimes)) + ' WHERE segment_id=' + str(segment))
  time.sleep(0.25)
开发者ID:geodarcy,项目名称:winterbiking,代码行数:32,代码来源:updateRatios.py

示例3: print

# 需要导入模块: from stravalib.client import Client [as 别名]
# 或者: from stravalib.client.Client import get_segment_leaderboard [as 别名]
    # get athlete activities
    activities = client.get_activities(limit=200)  # 3
    print("number of activities returned", str(len(list(activities))))

    # per activity, get segment efforts
    for activity in activities:
        segment_efforts = client.get_activity(activity.id).segment_efforts  # 4

        # per segment effort
        for segment in segment_efforts:
            mysegments[segment.segment.id] = segment.segment  # save to db

    # check if segment leaderboard contains any friends
    for key, segment in mysegments.iteritems():
        leaderboard = client.get_segment_leaderboard(key, following=True).entries  # 12

        # get friend with time < athlete time
        for person in leaderboard:
            if person.athlete_id == 1869056:
                me = person
                index = leaderboard.index(me)
                if index > 0:
                    other = leaderboard[index - 1]
                    data = {}
                    data['segment_name'] = segment.name
                    data['person_ahead'] = other.athlete_name
                    data['distance'] = str(unithelper.miles(segment.distance))
                    data['my_elapsed_time'] = str(me.elapsed_time)
                    # data['my_moving_time'] = str(me.moving_time)
                    data['their_elapsed_time'] = str(other.elapsed_time)
开发者ID:wilson0xb4,项目名称:strava-friend-breaker,代码行数:32,代码来源:strava-explore.py


注:本文中的stravalib.client.Client.get_segment_leaderboard方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。