# |
Apr 24th 2021, 20:31 |
kevin.pfeifer |
but thx for the answers :) |
# |
Apr 24th 2021, 20:31 |
kevin.pfeifer |
yep, seems like it |
# |
Apr 24th 2021, 20:28 |
kevin.pfeifer |
mhmm ok |
# |
Apr 24th 2021, 20:28 |
kevin.pfeifer |
I also think one major problem we have here is the fact, that we check for tasks every 3 seconds |
# |
Apr 24th 2021, 20:27 |
kevin.pfeifer |
yea the "spawn every 1min" is an approach i am thinking of |
# |
Apr 24th 2021, 20:25 |
slackebot |
every 30mins" is a good idea or if there are "better" ways :) Because i guess we run into the problem because 2 workers wait 3 seconds at the same time and try to fetch a task at the same time. So I guess another solution would be to (somehow) force the workers to check for tasks on different time periods, but I don't know how/if its possible. |
# |
Apr 24th 2021, 20:25 |
kevin.pfeifer |
well my problem here is, that 1 deploy task can be fetched multiple times if the given reference (my repo/branch name to deploy) is not the same. (because its a generic deploy task for all websites) Only tasks that have the same reference should be stopped to be fetched (which we currently do via a extra request in the deploy task) But i was more curious if the 30min "lifetime" of a worker with the "spawn a new worker |
# |
Apr 24th 2021, 20:13 |
dereuromark |
The latest Version contains a costs Option and that can prevent one type of task fetched more than once. So no parallel processing. |
# |
Apr 24th 2021, 19:35 |
slackebot |
are creating new worker instances every 30min. I guess there are better approaches to do what we want but I am just curious what your experiences are :) |
# |
Apr 24th 2021, 19:35 |
slackebot |
the tasks if the given repo/branch is already deployed right now but still we very rarely run into the same problem. Now my guess is, that we should change how/how often our workers are fetching the tasks from the queue. Currently we allow a maximum of 4 parallel workers to be run where each worker checks every 3 seconds if a task can be fetched. Each worker can live up to 30min before it kills itself when it has nothing to do and we |
# |
Apr 24th 2021, 19:35 |
kevin.pfeifer |
I have got a more "general" queue worker question for you all in here :) We are using https://github.com/dereuromark/cakephp-queue to do several tasks of which one is to deploy repositories onto DEV or LIVE websites. All that is working pretty well but sometimes we run into the problem, that 2 "identical" deploy tasks are fetched at the same time by 2 different worker tasks. We tried to mitigate that by checking inside |
# |
Apr 24th 2021, 18:00 |
ndm |
Pretty much, yeah. |
# |
Apr 24th 2021, 17:57 |
mehov |
Got it. So to summarise, if I were to stick with the abbreviation, the least problematic way (programming-wise) is to follow convention-over-configuration, and go with "B2c", right? The only complication then would be things looking strange here and there, but I can learn to live with that :) |
# |
Apr 24th 2021, 17:52 |
slackebot |
:upside_down_face: Give it a try. |
# |
Apr 24th 2021, 17:52 |
ndm |
@mehov Sure, routes can be changed easily with the `path` option, that's easy. Translation domains can be customized too, but it's not as straightforward, you'd have to define the loads for a domain/locale manually: https://book.cakephp.org/4/en/core-libraries/internationalization-and-localization.html#creating-your-own-translators Using all lowercase... actually I'm not sure about the implications, I guess it would work |
# |
Apr 24th 2021, 17:51 |
kevin.pfeifer |
what about calling it `BusinessToCustomer` ? ,:) |
# |
Apr 24th 2021, 17:50 |
mehov |
And to take this to the opposite direction, can I maybe name my plugin "b2b" or "crm", i.e. all lowercase? That should avoid the translation and URL issue |
# |
Apr 24th 2021, 17:50 |
mehov |
Hi @ndm, thank you for your answer! If I remember right, I can change the URL path using config routes. But can I change the plugin domain for translations, or I will be stuck with `b2_c`? |
# |
Apr 24th 2021, 17:45 |
ndm |
@mehov You can basically name it whatever you want as long as it's valid according to composer. If you bake your plugin, you might have to change things like the default URL path, which would be `b2-c` as uppercase chars denote words. Also the plugin domain for translations would be `b2_c` I think, which is a bit awkward, but IIRC that's about it. |
# |
Apr 24th 2021, 17:44 |
mehov |
Same with CRM by the way, should it be "CRM" or "Crm"? Both plugins are for internal use, so won't be published (and therefore don't need to be prefixed with "cakephp-". |
# |
Apr 24th 2021, 17:28 |
mehov |
Hi everyone, I'm baking a plugin for B2C. Am I supposed to name it "B2c" according to the convention? I don't like how that looks, and I'd prefer the common uppercase spelling. Am I going to regret it somewhere down the road? Should I stick to the "B2c" spelling, or can I go with "B2C"? |
# |
Apr 23rd 2021, 19:42 |
slackebot |
'/my-controller-name/ajax-get-offers/' + 1234, headers : { 'X-CSRF-Token': $('[name="_csrfToken"]').val() }, success: function(data, textStatus, jqXHR){ console.log(data) }, });``` As you can see you need a valid `_csrfToken` which you will get from any valid `<form>` created by the FormHelper in your cakephp template |
# |
Apr 23rd 2021, 19:42 |
slackebot |
/my-controller-name/ajax-get-offers/1234 then $id will be 1234 $data = ["test" => "hello!"]; $this->autoRender = false; return $response->withType( 'application/json' ) ->withStringBody( json_encode( [ 'data' => $data ] ) ); } }``` then call that function via the usual cakephp naming conventions like that in your ajax call ``` $.ajax({ type: 'get', url: |
# |
Apr 23rd 2021, 19:42 |
kevin.pfeifer |
the “short” gist of it is the following: create a controller function which you want to call via ajax ``` public function ajaxGetOffers( $id = null ): Response { $request = $this->getRequest(); $response = $this->getResponse(); if( $request->is( 'ajax' ) andand $request->is( 'get' ) ) { // TODO: Do your loading of your data here. // If this function is called via |
# |
Apr 23rd 2021, 19:23 |
sebastiansperandio093 |
Hello everyone, Hello everyone, could someone help me about how is the best cakephp's way to make an ajax request from a view that contain a form? I need to populate a dynamic select element in the form. I just need a documentation link or whatever....thanks! |
# |
Apr 23rd 2021, 18:05 |
tyler.adam.lazenby |
:) |
# |
Apr 23rd 2021, 18:05 |
kevin.pfeifer |
well, probably something for quick prototyping |
# |
Apr 23rd 2021, 18:05 |
kevin.pfeifer |
i see |
# |
Apr 23rd 2021, 18:05 |
tyler.adam.lazenby |
it was suggested in the entity documentation |
# |
Apr 23rd 2021, 18:04 |
tyler.adam.lazenby |
:) |
# |
Apr 23rd 2021, 18:04 |
tyler.adam.lazenby |
yes |
# |
Apr 23rd 2021, 17:39 |
kevin.pfeifer |
you mean this, right? https://github.com/jeremyharris/cakephp-lazyload |
# |
Apr 23rd 2021, 17:38 |
tyler.adam.lazenby |
its nice |
# |
Apr 23rd 2021, 17:38 |
kevin.pfeifer |
but i will have to take a look at that lazyload trait, it seems pretty cool :thinking_face: |
# |
Apr 23rd 2021, 17:36 |
kevin.pfeifer |
the "default", as little code as possible, cakephp way is just preconfigured with quite easy to understand defaults |
# |
Apr 23rd 2021, 17:36 |
tyler.adam.lazenby |
Yup, thanks for your help |
# |
Apr 23rd 2021, 17:35 |
kevin.pfeifer |
you can basically create any assiciation as you like |
# |
Apr 23rd 2021, 17:35 |
kevin.pfeifer |
so as you see |
# |
Apr 23rd 2021, 17:35 |
kevin.pfeifer |
:) |
# |
Apr 23rd 2021, 17:35 |
tyler.adam.lazenby |
That .... actually makes sense |
# |
Apr 23rd 2021, 17:34 |
kevin.pfeifer |
since you used `'propertyName' => 'User',` |