Update several thousand page attributes

Permalink
I have several thousand pages at the moment (a few over 3000), and each page has a scored assigned to it (number attribute)

I need to update this score every day.

At the moment, I've created a job that will get a pagelist of all these pages, and then loop through them all updating the score attribute.


Is there any faster way of doing this? Only it takes several minutes, and can sometimes memory out.

adz
 
JohntheFish replied on at Permalink Reply
JohntheFish
You could turn the job into a queueable job that breaks the loop into slices. Have a look at the core sitemap job for an example.

You could build the update into the pages, either writing a small block to do it or using Magic Data + Black Magic Data. So each time a page was loaded it checked and updated its own attribute. If you don't like the overhead when the page loads, you could defer it into an ajax callback using blocks by ajax.

You could use an on_before_render or on_render_complete event handler to do similar.
adz replied on at Permalink Reply
adz
Hi John,

Thanks for the reply, for some reason ths blog didn't email me telling me someone had replied,

I ended up just doing it via sql rather than using pagelists, as it was just too data/memory/resource intensive trying to do it through standard concrete5 models.