Skip to content

Conversation

barisgit
Copy link
Contributor

@barisgit barisgit commented Aug 2, 2025

  • Add ability to batch update parts from info providers

Works in the following way:

  1. User selects parts from any table and chooses action 'Bulk import from info provider'
image
  1. Gets redirected to step 1, where the user needs to choose how to search for parts (eg. user mpn to search on LCSC and MOUSER and at the same time use lcsc spn to search on LCSC)
image image
  1. Upon clicking "Search all parts", the server searches for all parts at once, presenting user with similar interface to single part import but for multiple parts, while at the same time creating a row in a new table 'bulk_info_provider_import_jobs' so that the progress is not lost upon refreshing. Optionally user can also check to prefetch details for every part in this stage (if the search returns too many parts, for example if we were to search by a vague keyword, this could mean it takes a long time, but can be prevented by choosing supplier part numbers instead). Prefetched data gets automatically stored in cache
image
  1. The job is then available to be opened from tools pane as well. On the job pane the user is presented with a list of all parts, where each part has search results. When user clicks update part they get redirected to info provider edit, with additional query parameter that tells page it is associated with a job. This way once saving part there is a button to go back, but at the same time mark part as completed in a job.
image image image

Note: I have by a mistake continued to work right on top of my other addition (excel support), so it would be best to first finish that or maybe even discard it and do everything here.

Copy link

codecov bot commented Aug 2, 2025

Codecov Report

❌ Patch coverage is 73.55649% with 316 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.35%. Comparing base (8b417d6) to head (66f7629).
⚠️ Report is 7 commits behind head on master.

Files with missing lines Patch % Lines
...rc/Controller/BulkInfoProviderImportController.php 56.15% 171 Missing ⚠️
src/Controller/PartController.php 43.75% 27 Missing ⚠️
...Form/InfoProviderSystem/BulkProviderSearchType.php 0.00% 19 Missing ⚠️
...foProviderSystem/PartProviderConfigurationType.php 0.00% 19 Missing ⚠️
src/Services/EntityMergers/Mergers/PartMerger.php 5.00% 19 Missing ⚠️
src/Services/ImportExportSystem/EntityImporter.php 83.52% 14 Missing ⚠️
src/Entity/Parts/Part.php 7.69% 12 Missing ⚠️
...ices/InfoProviderSystem/Providers/LCSCProvider.php 83.33% 11 Missing ⚠️
src/Entity/BulkInfoProviderImportJob.php 94.90% 8 Missing ⚠️
src/Services/Parts/PartsTableActionHandler.php 11.11% 8 Missing ⚠️
... and 3 more
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #982      +/-   ##
============================================
+ Coverage     59.83%   61.35%   +1.51%     
- Complexity     6050     6326     +276     
============================================
  Files           529      542      +13     
  Lines         20625    21730    +1105     
============================================
+ Hits          12341    13332     +991     
- Misses         8284     8398     +114     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@barisgit
Copy link
Contributor Author

barisgit commented Aug 2, 2025

Here is description of excel functionality pull report

  • Allow using xlsx and xls to import parts
  • Update example csv to better show what is possible
  • Add required tests (PASS)
  • Fix parts merger when using update from info supplier to consider parts that already have a spn populated a duplicate

…import jobs to junction table and implement filtering based on bulk import jobs status and its associated parts' statuses.
@barisgit
Copy link
Contributor Author

barisgit commented Aug 2, 2025

Added a tab for filtering by job statuses and such
image

@barisgit
Copy link
Contributor Author

barisgit commented Aug 4, 2025

Do not merge yet, there is a bug when user doesn't check prefetch and it still fetches info, causing timeout on larger sets.

@barisgit
Copy link
Contributor Author

barisgit commented Aug 4, 2025

Add priority support in mapping table
image
image

@barisgit
Copy link
Contributor Author

barisgit commented Aug 26, 2025

Hey @jbtronics any clue when this could be merged/rejected? Otherwise we will need to continue on our own fork, not providing any contributions here anymore.

@jbtronics
Copy link
Member

I will try to release the V2 version in the next few days, it's basically only missing some documentation. Then I can review and merge the PRs.

As some base stuff changed, it will probably be easier to merge the PRs into the V2 changes than the other way around....

@jbtronics
Copy link
Member

I have started reviewing the PR. I have rebased it on the master branch with v2. As i wasn't sure if I am allowed to force push and overwrite your branch (or if you are using it for something else), there is now a branch with the same name in the main repo. If you have no problem with the force push, just say it, and i will do it (makes some PR features a bit easier i think).

I really like the feature, its nicely done in the WebUI.
I have already changed some few things related to the v2 changes so far and some smaller things related to the excel exports.

I am not finished with the review, but some remarks so far:

  • The BulkInfoProviderImportController is really long and complex. I think functionality like the serialization/deserialization can be moved to the entities. Maybe introducing some DTOs instead of the complex arrays and move some of the logic to a service which is independent of the form handling would help too.
  • I don't really like the special handling for the batch handling of LCSC. It is not really intrinsically unique to LCSC, and should be more universally available. I already created a new BatchInfoProvider interface, that if implemented make the searchKeywordsBatch method implementable by all info providers. The decision whether to use the batch or individual import should be based on this interface. Not hardcoded for LCSC
  • The inline scripts in the templates will most likely not work in productive use, as then the Content-security-policy is active that will block this. Either you need to put it into a js file that will get included, a stimulus controller, or you need to add a nonce to the inline script tag. But i haven't tried out this so far and i don't know how good this work with turbo.

@barisgit
Copy link
Contributor Author

barisgit commented Sep 1, 2025

You may force push, I have my fork just to contribute, I have no plans to have own features on it.

  • Do you want me to refactor BulkInfoProvider or will you do it in V2?
  • Regarding hardcoded LCSC supplier number import I agree, but will BatchInfoProvider interface allow to search by supplier numbers? I haven't really tested with other than LCSC and Mouser as I don't regularly use others, but on them at least searching by MPN on batch input returns a very large number of results, which overloads API or in case of LCSC temporarily bans your ip, because it tries to then fetch datasheets and so on.

@jbtronics
Copy link
Member

Regarding hardcoded LCSC supplier number import I agree, but will BatchInfoProvider interface allow to search by supplier numbers?

I would say that the batch search will just work like the single searches and search for a keyword. What the provider does with that is, is the choice of the provider (and will be limited by the API). Maybe one can pass an optional argument to demark what kind of information this is, to give the provider a hint. That could also be useful to have on the single search

I haven't really tested with other than LCSC and Mouser as I don't regularly use others, but on them at least searching by MPN on batch input returns a very large number of results

Thats why I would implement it as on seperate interface. If it can be useful done for an provider (and somebody wants to implement it for an interface), then the batch methods will be used, otherwise not (and they do not exist on the provider then).

It would probably be the easiest if you could rewrite the controller to the more generic system of bulk info providers. I tried it yesterday and saw no easy way to do so, and would probably need more time to understand how the current code works...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants