Qurerying the DB to get all groups' users

Hello everyone,
querying the DB,I need to get all the users who can write/read the Wiki pages belonging to each project. To me a project is a collection of xwiki pages which can be edited by a determined work group.
I managed to get the project a page belongs to by using this query:

select
xwd_id,
xwd_fullname,
xwd_name,
xwd_title,
xwd_language,
xwd_default_language,
xwd_translation,
xwd_date,
xwd_content_update_date,
xwd_creation_date,
xwd_author,
xwd_content_author,
xwd_creator,
xwd_web,
case when array_path[1]=‘Progetti’::text then array_path[2]
else array_path[1]
end as cod_prog_xwiki

from
(SELECT *, regexp_split_to_array (xwd_fullname, E’\.’) as array_path
_ FROM xwiki.xwikidoc inner join xwiki.xwikispace on xwikispace.xws_reference = xwikidoc.XWD_WEB) t_

Although I don’t know how to separate the pages belonging to a project from other Xwiki stuff in the table xwikidoc (any hint?).

Once I get the projects, I would also like to have the list of users who are enabled on each one but I’m struggling to get that.

I think I can get all the groups in this way, but after that how can I go on?

select * from
_xwiki.xwikilargestrings ls _
where xwl_name=‘groups’

Can anyone suggest how I should proceed? Thanks!