Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # the modern version for a modern world
- def getSomeRawData_2(iRawData, guid, sortOrder):
- print "uasjsjakd"
- posts = iRawData.getOrderedPosts(guid, startTime=START_TIME, stopTime=STOP_TIME, sortOrder = sortOrder)
- allPostsList = list()
- postsToReturn = list()
- # fill list with 600 posts or all the posts if total posts of guid < 600
- for _ in range(600):
- try:
- post = posts.next()
- allPostsList.append(post)
- #allPostsList.append(posts.next())
- except StopIteration:
- break
- if len(allPostsList) == 0:
- print "kuk"
- return []
- # get start & stop indexes.
- if len(allPostsList) > 100:
- startIndex = random.randint(0, (len(allPostsList) - 100))
- stopIndex = startIndex + random.randint(50,100)
- else: # if low amount of posts, just take a chunk from beginining.
- startIndex = 0
- stopIndex = random.randint(50,100)
- # For starttime, we need all the posts of timestamp,
- timestamp = allPostsList[startIndex].created
- timestamp = timestamp.replace(microsecond=0)
- print "ayyoo"
- # get the posts that has same timestamp as starting index.
- indexChanged = 0
- for index in range (startIndex,0):
- if allPostsList[index].created.replace(microsecond=0) == timestamp:
- startIndex=-1
- indexChanged+= 1 #debug
- else:
- print "indexChanged: ", indexChanged
- break
- print "returning data for guid " + str(guid) + " lenght of stuff" + str(len(allPostsList))
- return allPostsList[startIndex:stopIndex]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement