This query might be close to what you want, tweak to suit eg. add a WHERE user_id = an id for a single user
SELECT
user_actions.user_id
, array_agg(DISTINCT user_actions.acting_user_id)
FROM user_actions
WHERE
user_actions.action_type = 2
GROUP BY user_actions.user_id
“2” is “liked” and “acting_user_id” is the “giver”
You may prefer to use AR pluck, but it would be the same table