select i2.identity_public_id as impersonator_public_id , i3.identity_public_id as target_public_id , i.created_at from impersonator i join identity i2 on i.impersonator_id = i2.identity_id join identity i3 on i.target_id = i3.identity_id join credential c using (credential_id) where (($1 is null) or (i2.identity_public_id = $1)) and (($2 is null) or (i3.identity_public_id = $2)) and c.revoked_at > $3;