Skip to content
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

NEW : Stock at date column is sortable / filterable in stockatdate.php page #32215

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from

Conversation

jyhere
Copy link
Contributor

@jyhere jyhere commented Dec 3, 2024

For the needs of a customer, I reworked the logical part (sql & php) of the stockatdate.php page to be able to sort / filter on the Stock at date column, in particular to be able to output all stock at date greater than 0.
Tested on fairly large volumes (+22000 products, +40000 stock movements), performance was similar to the previous code. (sql part is about 0.25s on by dev laptop for 500 results per page)

image

@eldy eldy added the PR to fix - Conflict or CI error to solve The PHP unit tests return something wrong. Check details to know what to fix or solve the conflicts. label Dec 8, 2024
@jyhere
Copy link
Contributor Author

jyhere commented Dec 9, 2024

This is a false positive: $stock_at_date is always defined because the condition in which it is found is always the same. But I've modified the code to overwrite the $objp->stock_at_date property instead, which is a useless property in future mode.

@frederic34 frederic34 removed the PR to fix - Conflict or CI error to solve The PHP unit tests return something wrong. Check details to know what to fix or solve the conflicts. label Dec 17, 2024
@eldy
Copy link
Member

eldy commented Dec 24, 2024

Lets summarize.
The algorithm of old code:

  • We take all product and their current stock into an array.
  • We take all past stock movement for each product into an array
    We combine the two array to get the result.

The algorithm of the new code.

  • We get the list of all product with a join on a subquery to get all stock and a join on a subquery to get all stock movement. Substraction is done inside the main SQL allowing to use the HAVING instruction.

Looking at code only, your second method seems to be slower compared to old one. Testing on less than 100 000 record is not significant. We know a lot of users of Dolibarr have more than 500 000 reference. I think problem may appears only with such a volume. But may be not.

Can someone with a very large database of product/stock/movement can take the code of the new page and run it to say if its ok for them ?

@eldy eldy added Discussion Some questions or discussions are opened and wait answers of author or other people to be processed PR waiting more user feedbacks We are waiting feedback of someone or more testers to validate this PR labels Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Discussion Some questions or discussions are opened and wait answers of author or other people to be processed PR waiting more user feedbacks We are waiting feedback of someone or more testers to validate this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants