How to save the failed_at field as ISODate? #2605
Replies: 1 comment 1 reply
-
Reading the laravel code, I see that the type of the laravel-mongodb/src/Queue/Failed/MongoFailedJobProvider.php Lines 25 to 34 in 9bc8999 I agree that an UTCDateTime should be used. Would you like to submit a PR? Also, it looks like the Job Batching feature implemented in Laravel 8.x needs some update. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, Before telling the solution, I must say that if the configuration considered for
failed.driver
in thequeue.php
file isdatabase-uuids
by default, the value of thefailed_at
field in Mongo is an empty object and no date is stored in it.But if we change the driver to mongodb, you will see that the date is stored as a string of the
timestamp
value in thefailed_at
field. And this was not what I expected and I wanted the date to be stored as an ISODate.However, to save the date in the
failed_at
field as ISODate, you can take the following steps.Step 1:
Run the following command
Then rewrite the
CustomMongodbQueueServiceProvider.php
file as below:Step 2:
Run the following command :
Then rewrite the
CustomMongoFailedJobProvider.php
file as below:I think it is generally clear what we did, a simple override of two service providers related to
MongoFailedJobProvider
,MongodbQueueServiceProvider
through which we can rewrite thelog
method according to our needs.Step 3:
Now we have to register our service provider in the
config/app.php
file :Step 4:
Then run the following command :
Well, our work is finished, now you can test the result. I hope this solution helped you.
Beta Was this translation helpful? Give feedback.
All reactions