Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RoomEndpoint sometimes not in executable_summary table yet #51

Open
Puckoland opened this issue Dec 6, 2024 · 0 comments
Open

RoomEndpoint sometimes not in executable_summary table yet #51

Puckoland opened this issue Dec 6, 2024 · 0 comments
Assignees

Comments

@Puckoland
Copy link
Collaborator

Compartment::getRoomEndpoints() sometimes skips RoomEndpoints because they are fetched lazily. Hence, they are not instances of RoomEndpoint but HibernateProxy#RoomEndpoint instead.

    @Transient
    public List<RoomEndpoint> getRoomEndpoints()
    {
        List<RoomEndpoint> roomEndpoints = new ArrayList<RoomEndpoint>();
        for (Executable childExecutable : getChildExecutables()) {
            if (!(childExecutable instanceof RoomEndpoint)) {
                continue;
            }
            RoomEndpoint roomEndpoint = (RoomEndpoint) childExecutable;
            roomEndpoints.add(roomEndpoint);
        }
        return roomEndpoints;
    }

While adding getLazyImplementation() to unproxy and resolving this problem, I found another problem in RoomEndpoint::toApi(), which uses the executable_summary table, and there is no given RoomEndpoint yet.
(executable_summary table is updated manually using Executable::updateExecutableSummary())

// RoomEndpoint::toApi()
// Determine whether room has recording service and recordings
// (use executable_summary for used_room_endpoints to be taken into account)
// Sometimes there is no data yet in executable_summary, so we must use the original query (see below)
Object[] result = (Object[]) entityManager.createNativeQuery(
    "SELECT room_has_recording_service, room_has_recordings FROM executable_summary WHERE id = :id")
    .setParameter("id", getId())
    .getSingleResult();
    public void updateExecutableSummary(EntityManager entityManager, boolean deleteOnly)
    {
        entityManager.flush();
        ExecutableManager executableManager = new ExecutableManager(entityManager);
        executableManager.updateExecutableSummary(this, deleteOnly);
    }

For now, as a workaround, we can either use executable_summary_view or join the tables directly:

"SELECT room_has_recording_service, room_has_recordings FROM executable_summary_view WHERE id = :id"

// or

"""
SELECT
    COUNT(recording_service.id) > 0 AS room_has_recording_service,
    COUNT(recording_service.id) > 0 OR COUNT(resource_room_endpoint_recording_folder_ids.recording_folder_id) > 0 AS room_has_recordings
FROM used_room_endpoint
LEFT JOIN used_room_endpoint AS room_endpoint_usage ON room_endpoint_usage.room_endpoint_id = :id
LEFT JOIN executable_service ON executable_service.executable_id = :id OR executable_service.executable_id = room_endpoint_usage.id
LEFT JOIN recording_service ON recording_service.id = executable_service.id
LEFT JOIN resource_room_endpoint_recording_folder_ids ON resource_room_endpoint_recording_folder_ids.resource_room_endpoint_id = :id OR resource_room_endpoint_recording_folder_ids.resource_room_endpoint_id = used_room_endpoint.room_endpoint_id
WHERE used_room_endpoint.id = :id
"""
@Puckoland Puckoland changed the title RoomEndpoint RoomEndpoint sometimes not in executable_summary table yet Dec 6, 2024
@Puckoland Puckoland self-assigned this Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant