Fixed get previous item in newsfeed buffer. Now it should load around 700 items

This commit is contained in:
Manuel Cortez 2019-02-11 03:55:16 -06:00
parent 6a8459cc4e
commit fbada0c4be
2 changed files with 3 additions and 5 deletions

View File

@ -108,7 +108,7 @@ class baseBuffer(object):
[self.insert(i) for i in self.session.db[self.name]["items"][:num]] [self.insert(i) for i in self.session.db[self.name]["items"][:num]]
else: else:
if num > 0: if num > 0:
[self.insert(i, False) for i in self.session.db[self.name]["items"][:num]] [self.insert(i, False) for i in self.session.db[self.name]["items"][-num:]]
return retrieved return retrieved
def get_more_items(self): def get_more_items(self):

View File

@ -138,14 +138,12 @@ class vkSession(object):
log.debug("Params for sending to vk: %r" % (kwargs,)) log.debug("Params for sending to vk: %r" % (kwargs,))
data = getattr(self.vk.client.newsfeed, "get")(*args, **kwargs) data = getattr(self.vk.client.newsfeed, "get")(*args, **kwargs)
if data != None: if data != None:
if show_nextpage == False:
self.process_usernames(data) self.process_usernames(data)
# else:
# print data.keys(), len(data["items"]), data["next_from"]
num = self.order_buffer(name, data["items"], show_nextpage) num = self.order_buffer(name, data["items"], show_nextpage)
log.debug("Keys of the returned data for debug purposes: %r" % (list(data.keys()),)) log.debug("Keys of the returned data for debug purposes: %r" % (list(data.keys()),))
if "next_from" in data: if "next_from" in data:
self.db[name]["cursor"] = data["next_from"] self.db[name]["cursor"] = data["next_from"]
log.debug("Next cursor saved for data: {cursor}".format(cursor=data["next_from"]))
return num return num
def get_page(self, name="", show_nextpage=False, endpoint="", *args, **kwargs): def get_page(self, name="", show_nextpage=False, endpoint="", *args, **kwargs):