Commit a2db8697 authored by Maxime Gasselin's avatar Maxime Gasselin Committed by Romain Bignon

[bp] remove triplicate transaction in bp pro

The next_page navigation is totally illogical. In the next page button
you can return to the first transactions. Morever no logical pattern in
history url navigation can be exploited. Nevertheless, we can skip
these pages with the comparaison of the first transaction of the page.

Closes: 8257@zendesk 8318@zendesk 8292@zendesk 9235@zendesk 9589@zendesk
parent 02bb0b93
......@@ -592,6 +592,7 @@ class BProBrowser(BPBrowser):
self.location(v.path, params=args)
self.first_transactions = []
for tr in self.page.iter_history():
transactions.append(tr)
transactions.sort(key=lambda tr: tr.rdate, reverse=True)
......
......@@ -84,7 +84,27 @@ class ProAccountHistory(LoggedPage, MyHTMLPage):
@method
class iter_history(ListElement):
item_xpath = u'//div[@id="tabReleve"]//tbody/tr'
next_page = Link('//div[@class="pagination"]//li[@class="pagin-on-right"]/a')
def next_page(self):
# The next page on the website can return pages already visited without logical mechanism
# Nevertheless we can skip these pages with the comparaison of the first transaction of the page
next_page_xpath = '//div[@class="pagination"]//li[@class="pagin-on-right"]/a'
tr_xpath = '//tbody/tr[1]'
self.page.browser.first_transactions.append(CleanText(tr_xpath)(self.el))
next_page_link = Link(next_page_xpath)(self.el)
next_page = self.page.browser.location(next_page_link)
first_transaction = CleanText(tr_xpath)(next_page.page.doc)
count = 0 # avoid an infinite loop
while first_transaction in self.page.browser.first_transactions and count < 30:
next_page = self.page.browser.location(next_page_link)
next_page_link = Link(next_page_xpath)(next_page.page.doc)
first_transaction = CleanText(tr_xpath)(next_page.page.doc)
count += 1
if count < 30:
return next_page.page
class item(ItemElement):
klass = Transaction
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment