workflows: refactoring of holdingpen

* Implements caching for fast research sorting and else.

* Simplifies the code.

* Factorizes some code part.

Signed-off-by: Guillaume Lastecoueres <guillaume.lastecoueres@cern.ch>