-
Notifications
You must be signed in to change notification settings - Fork 0
[FIX] bedelia_api - Corrige semántica de modalidades, filtro de posprevias y paginación #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # Generated by Django 5.2.4 on 2026-08-04 00:32 | ||
|
|
||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('api', '0001_initial'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AddField( | ||
| model_name='pospreviaitem', | ||
| name='fecha', | ||
| field=models.DateField(blank=True, null=True, verbose_name='Fecha reportada por Bedelías'), | ||
| ), | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,11 +64,25 @@ def go_to_page(self, page: int): | |
| page_text == f"Page {page}" | ||
| ): | ||
| return | ||
| if page > 10 and (page_text == "Page 1" or page_text == "1"): | ||
| self.scroll_to_element_and_click(self.wait_for_element_to_be_clickable((By.XPATH, f'//a[contains(@class,"ui-paginator-last")]'))) | ||
| self.wait_for_page_to_load() | ||
| # The paginator only renders a window of ~10 page links. If the target | ||
| # link is not visible from the current position, step through blocks | ||
| # with the next/prev arrows until it appears (bounded to avoid looping). | ||
| target_xpath = f'//a[@aria-label="Page {page}"]' | ||
| self.wait.until(EC.invisibility_of_element_located((By.XPATH, '//div[@id="j_idt22_modal"]'))) | ||
| self.scroll_to_element_and_click(self.wait_for_element_to_be_clickable((By.XPATH, f'//a[@aria-label="Page {page}"]'))) | ||
| steps = 0 | ||
| while not self.try_find_element((By.XPATH, target_xpath)) and steps < 50: | ||
| steps += 1 | ||
| current = self.wait_for_element_to_be_visible( | ||
| (By.XPATH, '//a[contains(@class, "ui-state-active")]') | ||
| ) | ||
| current_label = current.get_attribute("aria-label") or current.text.strip() | ||
|
Comment on lines
+73
to
+78
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue: Current page parsing can raise ValueError if the label format changes or is non-numeric. This relies on |
||
| current_page = int(current_label.replace("Page", "").strip() or 1) | ||
| arrow = "ui-paginator-next" if page > current_page else "ui-paginator-prev" | ||
| self.scroll_to_element_and_click( | ||
| self.wait_for_element_to_be_clickable((By.XPATH, f'//a[contains(@class,"{arrow}")]')) | ||
| ) | ||
| self.wait_for_page_to_load() | ||
| self.scroll_to_element_and_click(self.wait_for_element_to_be_clickable((By.XPATH, target_xpath))) | ||
| self.wait_for_page_to_load() | ||
| self.logger.info("Waiting for loading to finish") | ||
| self.wait.until(EC.invisibility_of_element_located((By.XPATH, "//img[@src='/jakarta.faces.resource/img/cargando.gif.xhtml?ln=default']"))) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: Loop relies on next/prev arrows always being present, which can cause hangs at paginator boundaries.
At the first or last page, the chosen arrow link may be disabled or absent, causing
wait_for_element_to_be_clickableto block until timeout and making the bounded loop fail slowly or incompletely. Consider detecting paginator boundaries (e.g., arrow not found or not enabled) and breaking early with a clear error instead of continuing to loop.