Repository navigation
Item CSV Import Update and Optimizations - #2821
objecttothis wants to merge 55 commits into
Conversation
|
With these first two commits the update is working for base item data but not yet for updating attribute values. Still working on that, but so far this feature has been far easier than I thought it would be. |
|
@opensourcepos/org OK, I've got attributes updating. I begin testing tomorrow to make sure everything is in place. Feel free to play with it on the demo until someone pushes a commit on another PR. If the CSV import has an item_id in it, then the parser treats it like an update and should only update columns that are not blank and valid data. Please let me know anyone manages to break it so that I can work on the bugs. This has to be air tight. |
|
@objecttothis You probably hear me coming but I think the perfect way to test this kind of functionality is by adding some unit tests. Main challenge would be to stub out the db calls in this case, but it would be the easiest way to do some combinations of different types of inputs to see if the code behaves as expected. No obligations here, just an idea :) |
philosophically, I am 100% on board. This is a skillset that I need to learn and it would help the code. The dilemma that I'm in is that because of the quarantine, our bookstore has very few sales which means that getting the store eCommerce site up has become top priority. Every day that goes by for us, can mean the difference between our staff being out of work or not. Honestly, I think we as an @opensourcepos/org should always be moving toward requiring good dev practices and unit testing is one of them (where applicable). I just need to figure out how that practically needs to play out in this situation... food on the table for our staff or unit tests. ;) |
|
@opensourcepos/org OK, I've done the bulk of the testing (and fixing the bugs). Please have a look. It should be functioning in the demo as soon as the Travis-CI build completes. |
Of course I understand you need to keep going, I appreciate that you're making the effort to go through the designs here with us (as I guess it's benefical to all in the end). |
|
@objecttothis please focus on your online store. Consider Shopify as an option. I've overhauled my wife's online shop with Shopify right as the lockdown started. The lockdown will last two to three months at least. We are all still in it here in London. |
Thank you. Right now all the pull requests I am submitting here are to better get the data from OSPOS right and complete. I have another piece of software that will take ISBNs and scrape internet sites to pull all the metadata. This PR will allow me to then import that data into OSPOS which, with my CLCdesq API connector allow me to pump that data to the eCommerce site. Thanks for the recommendation on shopify. We have an inhouse CMS that another dev has been working on and I am just coming onboard with. It's C#/.NET so its a different animal, but RESTful APIs make that interaction a little easier. |
|
@opensourcepos/org does anyone have any time to download this from bintray and see if they can break it? I believe it's working, but want to get a second set of eyes on the code and build. |
6a15ade to
241da4e
Compare
|
What's the status of this? |
It's what I'm working on finishing now. Unfortunately I am finding that it brings MySQL to it's knees because we have some significant inefficiencies. There are many columns being used in JOINs that are not indexed and many that are used in WHERE clauses that are not indexed. Since the update hits a lot of data in the database, it causes buffering problems. I'm working on finding the columns that aren't indexed. I've also needed to make some optimization changes by pulling queries outside of the foreach loop that have results that do not change and just pass the results in. I've also found a number of other places related where the code can use some optimization. As an aside, this one is earmarked for 3.4.0 so don't let it hold up the release of 3.2.2. |
0273c7b to
3769eb4
Compare
|
@opensourcepos/org @daN4cat @jekkos This is ready for testing. In general, things should be snappier because of the added indexes and the changing of column types. I recommend running Major improvements:
Things that I've tested and need to be tested by anyone willing:
I was able to import 13,580 rows with 15-20avg number of attributes on each row and it did great. While I'm waiting for people to do code reviews @jekkos? @daN4cat? I'll see if I can get phpunit running and write unit tests (I know @jekkos will be happy). |
- There was a bug in the code that caused attribute_link rows to be duplicated with the same information on item_import with an update. This migration removes the duplicate rows.
5f12f66 to
e3c1828
Compare
|
@objecttothis I hope all is still ok on your side and that the situation in your country is not affecting you too much. But as 3.3.3 is near completion, I want to pick up your first PR here, but now see it might needs a refresh. Would you mind to rebase this on latest master and perhaps squash some of the commits to make it more easy to review? It might make our history log a bit cleaner.. unless you feel other reasons to have the whole commit history inlcuded? Thanks |
OK, I'll be working on this Tuesday when I'm back in the office. |
Changes not yet merged. Rebase on master Formatting Changes and optimization Set all imported items to undeleted by default Remove Duplicate links - There was a bug in the code that caused attribute_link rows to be duplicated with the same information on item_import with an update. This migration removes the duplicate rows. Fixed duplicate attribute_link bug - In the event that an item was being updated and the new attribute_value didn't exist, the old attribute_link was not being deleted which caused two attribute_link rows to exist with the same item_id and definition_id. Bug Fix - Corrected Saving of inventory quantities to allow 0 quantity to be entered. Rebase Rebase Fixing accidental revert Rebase Warning Fixes Rebase on Master Refactored function names Added Indexes - Three new indexes to fix a problem where item tables won't load with large databases due to how long the query takes. Formatting - Removed Leading underscores from functions and variables - Replaced " with ' where " was not necessary - Removed unnecessary whitespace and blank lines - Refactored variable names for clarity Bug fixes and Formatting - Fixed vertical indentation - Removed item_id assignment from Items->view() which is causing new items to get assigned string '-1' for item_id and confuses the save() function. - Assigned default item_id to NEW_ITEM for Items->attributes() function. - Refactored variable name for readability. - Extracted local variable for readability. - Replaced " with ' where not needed. - Removed unneeded comments - Reworked importfile_helper->get_csv_file for speed and readability - Reworked importfile_helper->bom_exists for readability - unset large arrays and set to null when not needed for garbage collection. - Corrected bug in Attribute->value_exists to correctly return attribute_id for attribute_date values that exist. - Fixed a bug in Attribute->save_value that caused two different query builders to be mixed when adding an attribute. - Replaced == with === for speed and safety. - Fixed position of " in daterangepicker Fixed missing " in daterangepicker Bug Fix - Fixed bug in pic_thumb() where an error would be generated if you tried to resize a file to something that already existed. Added check for a file name. rebase actions Bug Fixes and enhancements - Switched == and != for === and !== where possible. - Fixed indentation - replaced . concatenation with " and variables inside quotes where possible for readability. - Replaced " with ' where not needed. - Removed unneeded empty lines - Fixed bug in locale_helper causing parse_decimals to return string '0' when it should actually process it and return integer 0 - Corrected valid_date() in locale_helper to return based on the locale chosen Bug Fix - Fixed a Bug causing DATE duplicate removal to fail when two items had the same attribute_value Bug Fixes - Make data_error_check() error message for incorrect date match the requirement for the import data to match the set date locale. Formatting Fixes Fixed variable name Bug Fix - Corrected bug that does not convert attribute dates to system selected format which causes the save attribute logic to fail. Formatting changes Bug fixes - Reverted some === to == unil unit tests could be written to confirm they do not break things. - Corrected value_exists function to properly check for date attributes - Removed unused variables. - Removed call to delete_orphaned_values because it is causing problems - Fixed code formatting - Removed trailing whitespace and whitespace on blank lines Code Cleanup - Removed unused variables - Initialize variables that were not initialized before being used. - Replaced " for ' in PHP where " was not needed. - Replaced " for ' in HTML where possible for consistency. - Fixed bug in Item-kit - Fixed bug in Item->get_search_suggestions where a join was done without specifying the table. - corrected Item->get_kit_search_suggestions search_custom query to actually query the attributes table rather than the deprecated and removed custom fields. Code formatting and cleanup - Correcting   to - replacing " for ' for consistency in the code - Removing trailing whitespace - Removing whitespace on empty lines - Removed unneeded comments - corrected </div> to </textarea> Fixed syntax error Optimizations - Replace array_push() with []. - Rename Attribute->undelete() to Attribute->undelete_definition() for consistency in naming conventions. - Added call to delete_orphaned_values when an attribute_link row is deleeted to prevent orphaned_value rows from forming. - Clarified javadoc comments - Removed trailing whitespace - Removed whitespace on empty lines Further optimization to CSV import Additional formatting and bug fixes Bug fixes - Fixed a problem causing quantities to not be properly stored. - Added a check to fail a line if an item_id is provided that does not exist. Resort query order - Resorted order to take advantage of query indexes in the database. Formatting and code cleanup - Added NEW_ITEM constant - Renamed variables for clarity - Tab indentation of equals signs for easy of reading - Removed unnecessary comments - Removed unecessary variable. - Renamed CSV headings to for consistency with other headings - Remove method chaining for clarity. - Replaced array() and new Array() with [] for speed (+20%) and to match current standard. - Removed trailing whitespace and whitespace on empty lines Reverted Method Chaining changes Requested changes and bug fixes - Fixed a bug causing attribute conversion to fail. - Code cleanup and optimization in the convert_definition_data method. - Reverted method chaining in query builder methods for readability. - Resorted Attribute model to original method order for clarity in code review. Optimization - Cleaned up code - Optimized out 1 query call per attribute per row in import file. Added to Migration SQL - Changed some columns from tinyint to tinyint(1) - Removed from querybuilder calls to optimize speed. Regression Fix Rebase Rebase Rebase Queries Allow empty quantity field Attribute import update fixes - Corrected bug in Items->data_error_check preventing dates from being checked properly. - Fixed attribute save to properly account for decimal and date updates. Update attribute values Rebase on Master
…port_update # Conflicts: # application/models/Sale.php # application/views/configs/system_info.php # application/views/partial/stock_locations.php # application/views/sales/quote_email.php
|
@jekkos I rebased this branch on the master, but I have not been able to squash the commits together. I've tried it both with PHPStorm and Eclipse. PHPStorm is proving to be a lot easier to use than Eclipse, but it still would not squash commits. It gives me an error telling me that the commits I'm trying to squash have two parents. That said, the conflicts with the master have been resolved. |
|
@objecttothis thank you for that already. I can try to do the squash for you. |
|
@objecttothis I have squashed all work in one commit in item-import-update branch in this repo Could you check out that branch and amend the commit so it has your name as author on it? I think there was a bit of an issue as indeed some of the commits had multiple parents and that made the rebase impossible to do. So what I did basically was
Squashing commits has a couple of advantages
But the downside is that you loose track of all the changes you actually did. However if the intention is to add just one feature, then in principle one commit per feature should be fine. |
|
@objecttothis If you agree we can continue the review on #3029 ? You can check that one out, amend the commit so it carries your name and authorship? |
|
So sorry. I went on vacation this week and then got diagnosed with COVID-19 today. This kind of thing seems to happen every time I go on vacation. Yes please continue the code review on the other PR and I'll change the author on the commit. |
OK, I changed the commit author on the other branch, so we can continue in that PR. The only difference is that PR is authored by @jekkos. I don't think that is an issue, because you can do a code review for your own PR, but if it is then the solution would be to keep the branch, close that PR (and this one) and then to have me create a PR with that branch. I did assign the PR that @jekkos authored to me though, so I should still get notifications. |
|
Ok maybe you should reopen it then. You can close the one I created. Thanks. |
|
@objecttothis take care of yourself, unplug from here and get well soon. Don't underestimate covid-19 even if it looks a mild thing at the beginning. |
|
@daN4cat thanks. I'll be back from vacation on Tuesday. I'm already in the tail end of the virus. At it's worst I was sleeping for 14 hour chunks. Glad to be out of that. @jekkos I don't mind you being the PR author. It has me as the commit author so that's fine. If someone wants to start a code review while I'm gone, that's fine. |
@objecttothis take care as @daN4cat says.... |
|
Closing this here since it's now being implemented in PR #3029 |
No description provided.