Skip to content

Commit

Permalink
Fixes #339
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Dec 20, 2024
1 parent 4228f23 commit 6b16a10
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
7 changes: 5 additions & 2 deletions client/src/tabs/Invitations.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,11 @@ export const Invitations = ({
key: "name",
header: I18n.t("invitations.inviter"),
mapper: invitation => <div className="user-name-email">
<span className="name">{invitation.name}</span>
<span className="email">{invitation.inviter_email}</span>
{invitation.inviter_email ? <>
<span className="name">{invitation.name}</span>
<span className="email">{invitation.inviter_email}</span>
</> : <span className="name">{invitation.remote_api_user}</span>}

</div>
},
{
Expand Down
20 changes: 10 additions & 10 deletions server/src/main/java/access/repository/InvitationRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public interface InvitationRepository extends JpaRepository<Invitation, Long>, Q
List<Invitation> findByStatusAndRoles_role(Status status, Role role);

@Query(value = """
SELECT i.id, i.email, i.intended_authority,i.created_at, i.expiry_date,
SELECT i.id, i.email, i.remote_api_user, i.intended_authority, i.created_at, i.expiry_date,
u.id as user_id, u.name, u.email as inviter_email
FROM invitations i INNER JOIN users u ON u.id = i.inviter_id
FROM invitations i LEFT JOIN users u ON u.id = i.inviter_id
WHERE i.status = ?1
""",
countQuery = "SELECT count(*) FROM invitations WHERE status = ?1",
Expand All @@ -41,15 +41,15 @@ public interface InvitationRepository extends JpaRepository<Invitation, Long>, Q
Page<Map<String, Object>> searchByStatusPage(String status, Pageable pageable);

@Query(value = """
SELECT i.id, i.email, i.intended_authority,i.created_at, i.expiry_date,
SELECT i.id, i.email, i.remote_api_user, i.intended_authority,i.created_at, i.expiry_date,
u.id as user_id, u.name, u.email as inviter_email
FROM invitations i INNER JOIN users u ON u.id = i.inviter_id
FROM invitations i LEFT JOIN users u ON u.id = i.inviter_id
WHERE i.status = ?1 AND
(MATCH(i.email) AGAINST(?2 IN BOOLEAN MODE)
OR MATCH (u.given_name, u.family_name, u.email) against (?2 IN BOOLEAN MODE))
""",
countQuery = """
SELECT count(*) FROM invitations i INNER JOIN users u ON u.id = i.inviter_id
SELECT count(*) FROM invitations i LEFT JOIN users u ON u.id = i.inviter_id
WHERE status = ?1 AND
(MATCH(i.email) AGAINST(?2 IN BOOLEAN MODE)
OR MATCH (u.given_name, u.family_name, u.email) against (?2 IN BOOLEAN MODE))
Expand All @@ -59,9 +59,9 @@ OR MATCH (u.given_name, u.family_name, u.email) against (?2 IN BOOLEAN MODE))
Page<Map<String, Object>> searchByStatusPageWithKeyword(String status, String keyWord, Pageable pageable);

@Query(value = """
SELECT i.id, i.email, i.intended_authority,i.created_at, i.expiry_date,
SELECT i.id, i.email, i.remote_api_user, i.intended_authority,i.created_at, i.expiry_date,
u.id as user_id, u.name, u.email as inviter_email
FROM invitations i INNER JOIN users u ON u.id = i.inviter_id INNER JOIN invitation_roles ir ON ir.invitation_id = i.id
FROM invitations i LEFT JOIN users u ON u.id = i.inviter_id INNER JOIN invitation_roles ir ON ir.invitation_id = i.id
INNER JOIN roles r ON r.id = ir.role_id
WHERE i.status = ?1 AND r.id = ?2
""",
Expand All @@ -76,9 +76,9 @@ SELECT count(*) FROM invitations i
Page<Map<String, Object>> searchByStatusAndRolePage(String status, Long roleId, Pageable pageable);

@Query(value = """
SELECT i.id, i.email, i.intended_authority,i.created_at, i.expiry_date,
SELECT i.id, i.email, i.remote_api_user, i.intended_authority,i.created_at, i.expiry_date,
u.id as user_id, u.name, u.email as inviter_email
FROM invitations i INNER JOIN users u ON u.id = i.inviter_id INNER JOIN invitation_roles ir ON ir.invitation_id = i.id
FROM invitations i LEFT JOIN users u ON u.id = i.inviter_id INNER JOIN invitation_roles ir ON ir.invitation_id = i.id
INNER JOIN roles r ON r.id = ir.role_id
WHERE i.status = ?1 AND r.id = ?2 AND
(MATCH(i.email) AGAINST(?3 IN BOOLEAN MODE)
Expand All @@ -88,7 +88,7 @@ OR MATCH (u.given_name, u.family_name, u.email) against (?3 IN BOOLEAN MODE))
SELECT count(*) FROM invitations i
INNER JOIN invitation_roles ir ON ir.invitation_id = i.id
INNER JOIN roles r ON r.id = ir.role_id
INNER JOIN users u ON u.id = i.inviter_id
LEFT JOIN users u ON u.id = i.inviter_id
WHERE status = ?1 and role_id = ?2 AND
(MATCH(i.email) AGAINST(?3 IN BOOLEAN MODE)
OR MATCH (u.given_name, u.family_name, u.email) against (?3 IN BOOLEAN MODE))
Expand Down

0 comments on commit 6b16a10

Please sign in to comment.