Refactor the query Add json update for pagination Change-Id: I8f9ffb67c928f95187e3429492d8e7893d24d61d