Advertisement
Guest User

Untitled

a guest
Jan 21st, 2020
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.43 KB | None | 0 0
  1.  
  2. # the modern version for a modern world
  3. def getSomeRawData_2(iRawData, guid, sortOrder):
  4.  
  5.     print "uasjsjakd"  
  6.  
  7.     posts = iRawData.getOrderedPosts(guid, startTime=START_TIME, stopTime=STOP_TIME, sortOrder = sortOrder)
  8.     allPostsList = list()
  9.     postsToReturn = list()
  10.     # fill list with 600 posts or all the posts if total posts of guid < 600
  11.     for _ in range(600):
  12.         try:
  13.             post = posts.next()
  14.             allPostsList.append(post)
  15.             #allPostsList.append(posts.next())
  16.         except StopIteration:
  17.             break
  18.     if len(allPostsList) == 0:
  19.         print "kuk"
  20.         return []
  21.  
  22.     # get start & stop indexes.
  23.     if len(allPostsList) > 100:
  24.         startIndex = random.randint(0, (len(allPostsList) - 100))
  25.         stopIndex = startIndex + random.randint(50,100)
  26.     else: # if low amount of posts, just take a chunk from beginining.
  27.         startIndex = 0
  28.         stopIndex = random.randint(50,100)
  29.  
  30.  
  31.     # For starttime, we need all the posts of timestamp,
  32.  
  33.  
  34.     timestamp = allPostsList[startIndex].created
  35.     timestamp = timestamp.replace(microsecond=0)
  36.     print "ayyoo"
  37.     # get the posts that has same timestamp as starting index.
  38.     indexChanged = 0
  39.     for index in range (startIndex,0):
  40.         if allPostsList[index].created.replace(microsecond=0) == timestamp:
  41.             startIndex=-1
  42.             indexChanged+= 1 #debug
  43.         else:
  44.             print "indexChanged: ", indexChanged
  45.             break
  46.     print "returning data for guid " + str(guid) + " lenght of stuff" + str(len(allPostsList))
  47.     return allPostsList[startIndex:stopIndex]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement