Exemple #1
0
def summarizeDurations(yakCursor, label):
  return
  print(label + ': Yak Lasting Duration')
  creationTimes = [yak.time for yak in yakCursor]
  finalLikeTimes = [(YakLikeCount.select().where(YakLikeCount.yak == yak.id)
    .order_by(YakLikeCount.time.desc()).get().time) for yak in yakCursor]

  durations = [] # fill up
  for i in range(len(creationTimes)):
    timeDelta = finalLikeTimes[i] - creationTimes[i]
    minutes = timeDelta.total_seconds() / 60.0
    durations.append(minutes)

  print(summaryString(durations))
  print('') # end with new line
Exemple #2
0
def writeUpvoteCSV(yakCursor, filename):
  return
  with open(filename, 'wb') as output:
    writer = csv.writer(output) # wraps stream
    writer.writerow(['Elapsed Minutes', 'Upvote Fraction'])

    # add points to scatterplot
    for yak in yakCursor:
      startTime = yak.time
      finalCount = yak.finalLikeCount
      if finalCount <= 0: continue
      for like in YakLikeCount.select().where(YakLikeCount.yak == yak.id):
        timeDelta = like.time - startTime # return type TimeDelta
        minutes = timeDelta.total_seconds() / 60.0
        if like.count <= 0: continue # avoid negative counts
        if like.count > finalCount: continue # avoid high fractions
        writer.writerow([minutes, float(like.count) / finalCount])