Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Commit

Permalink
skip finished rooms without recording and no corresponding rtc_stream
Browse files Browse the repository at this point in the history
if rtc_stream for a room is absent we cant fetch backend_id for this stream
so there is no way to obtain stream recording
  • Loading branch information
khodzha committed Aug 21, 2020
1 parent f560d45 commit d2934ec
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/db/room.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ pub(crate) fn finished_without_recordings(
.filter(room::backend.ne(RoomBackend::None))
.filter(schema::recording::rtc_id.is_null())
.filter(sql("upper(\"room\".\"time\") < now()"))
.filter(schema::janus_backend::id.is_not_null())
.select((
self::ALL_COLUMNS,
super::rtc::ALL_COLUMNS,
Expand Down Expand Up @@ -337,12 +338,23 @@ mod tests {

let room1 = shared_helpers::insert_closed_room(&conn);
let room2 = shared_helpers::insert_closed_room(&conn);

// this room will have rtc but no rtc_stream simulating the case when janus_backend was removed
// (for example crashed) and via cascade removed all streams hosted on it
//
// it should not appear in query result and it should not result in query Err
let room3 = shared_helpers::insert_closed_room(&conn);

let backend1 = shared_helpers::insert_janus_backend(&conn);
let backend2 = shared_helpers::insert_janus_backend(&conn);

let rtc1 = shared_helpers::insert_rtc_with_room(&conn, &room1);
let rtc2 = shared_helpers::insert_rtc_with_room(&conn, &room2);
let _rtc3 = shared_helpers::insert_rtc_with_room(&conn, &room3);

shared_helpers::insert_janus_rtc_stream(&conn, &backend1, &rtc1);
shared_helpers::insert_janus_rtc_stream(&conn, &backend2, &rtc2);

let rooms = finished_without_recordings(&conn)
.expect("finished_without_recordings call failed");
assert_eq!(rooms.len(), 2);
Expand Down

0 comments on commit d2934ec

Please sign in to comment.