internetztube / craft-element-relations

Shows all relations of an element.
https://plugins.craftcms.com/element-relations
Other
2 stars 5 forks source link

Adds Caching Layer and Console Comands #4

Closed gbowne-quickbase closed 2 years ago

gbowne-quickbase commented 2 years ago

Boy howdy was this fun! Lots of learning and looking how other plugin greats do things.

Should fix #3

internetztube commented 2 years ago

Wow, thanks for the pull request! Looks great at first glance! Will look closely with the PR the next few days!

internetztube commented 2 years ago

Hey Greg! @gbowne-quickbase The last few days I made a few adjustments based on your changes.

I appreciate your thoroughness regarding docblocks. However, I think that comments are not necessary everywhere. Of course, type hints are essential for class properties. But if all parameters of a function have a type, a return type, and a meaningful name, then in my eyes, a docblock is not absolutely necessary.

Please test the code changes again to see if everything works as expected. Thanks, again!

https://github.com/internetztube/craft-element-relations/tree/next https://github.com/internetztube/craft-element-relations/compare/858d4e59150f07d7bd1a1f2e460a73c3f2121435...next

gbowne-quickbase commented 2 years ago

Great! I'll give it a thorough test. The Queue jobs was a logical next step but I had to get back to my day job! My IDE encourages doc blocks and for me during development, I found them helpful to make sure I had things named correctly and semantically and to remind me to double check when things got renamed.

gbowne-quickbase commented 2 years ago

This seems to be working really well, and I appreciate the use of the Queue, since it's a long process. The only thing I miss is the create queue action which would find all the relevant items and build them out to speed up the initial load

internetztube commented 2 years ago

I have changed the logic so that there is only one cache refresh endpoint. Without --force, the missing and stale elements are recached. All elements with an Element Relations field are recached with --force.

php craft element-relations/refresh-cache --force

For the initial creation of the caches, a task gets pushed into the queue after the plugin gets enabled or installed.

gbowne-quickbase commented 2 years ago

That's a great way to do it! Thanks for all your rapid-cycle improvements on this. I hope it's been fun to work on again