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

Commit

Permalink
Fix compilation warnings (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
feymartynov committed Mar 23, 2020
1 parent 30441c6 commit faf0447
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 224 deletions.
2 changes: 1 addition & 1 deletion docs/src/api.room.update.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ backend | String | _optional_ | The room backend. Available values: janus,



## Unicast rxesponse
## Unicast response

If successful, the response payload contains an updated **Room** object.
2 changes: 1 addition & 1 deletion src/app/endpoint/room.rs
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ mod test {
assert_eq!(evt.properties().kind(), "event");
assert_eq!(evt.payload().id, room.id());

// Assert room abscence in the DB.
// Assert room absence in the DB.
let conn = db.connection_pool().get().unwrap();
let query = crate::schema::room::table.find(room.id());
assert_eq!(query.execute(&conn).unwrap(), 0);
Expand Down
2 changes: 1 addition & 1 deletion src/app/endpoint/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ mod test {

for rtc in rtcs.iter() {
room::UpdateQuery::new(rtc.room_id().to_owned())
.set_time(time)
.time(time)
.execute(&conn)
.unwrap();
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/janus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ pub(crate) async fn handle_event(
.ok_or_else(|| format_err!("a room for rtc = '{}' is not found", &rtc_id))?;

// Publish the update event if only stream object has been changed
// (if there was't any actual media stream, the object won't contain its start time)
// (if there weren't any actual media stream, the object won't contain its start time)
if let Some(_) = rtc_stream.time() {
let event = endpoint::rtc_stream::update_event(
room.id(),
Expand Down
16 changes: 0 additions & 16 deletions src/backend/janus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,14 +327,6 @@ pub(crate) struct WebRtcUpEvent {
}

impl WebRtcUpEvent {
pub(crate) fn session_id(&self) -> i64 {
self.session_id
}

pub(crate) fn sender(&self) -> i64 {
self.sender
}

pub(crate) fn opaque_id(&self) -> &str {
&self.opaque_id
}
Expand All @@ -353,14 +345,6 @@ pub(crate) struct HangUpEvent {
}

impl HangUpEvent {
pub(crate) fn session_id(&self) -> i64 {
self.session_id
}

pub(crate) fn sender(&self) -> i64 {
self.sender
}

pub(crate) fn opaque_id(&self) -> &str {
&self.opaque_id
}
Expand Down
16 changes: 2 additions & 14 deletions src/db/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pub(crate) struct Object {
status: Status,
}

#[cfg(test)]
impl Object {
pub(crate) fn id(&self) -> Uuid {
self.id
Expand Down Expand Up @@ -96,20 +97,6 @@ impl<'a> ListQuery<'a> {
}
}

pub(crate) fn offset(self, offset: i64) -> Self {
Self {
offset: Some(offset),
..self
}
}

pub(crate) fn limit(self, limit: i64) -> Self {
Self {
limit: Some(limit),
..self
}
}

pub(crate) fn execute(&self, conn: &PgConnection) -> Result<Vec<Object>, Error> {
use diesel::prelude::*;

Expand Down Expand Up @@ -172,6 +159,7 @@ impl<'a> InsertQuery<'a> {
}
}

#[cfg(test)]
pub(crate) fn status(self, status: Status) -> Self {
Self { status, ..self }
}
Expand Down
44 changes: 0 additions & 44 deletions src/db/agent_stream.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use chrono::serde::ts_seconds;
use chrono::{DateTime, Utc};
use diesel::{pg::PgConnection, result::Error};
use serde_derive::{Deserialize, Serialize};
use uuid::Uuid;

Expand All @@ -19,46 +18,3 @@ pub(crate) struct Object {
#[serde(with = "ts_seconds")]
created_at: DateTime<Utc>,
}

impl Object {
pub(crate) fn id(&self) -> Uuid {
self.id
}

pub(crate) fn sent_by(&self) -> Uuid {
self.sent_by
}

pub(crate) fn label(&self) -> &str {
self.label.as_ref()
}
}

////////////////////////////////////////////////////////////////////////////////

#[derive(Debug, Insertable)]
#[table_name = "agent_stream"]
pub(crate) struct InsertQuery<'a> {
id: Option<Uuid>,
sent_by: Uuid,
label: &'a str,
}

impl<'a> InsertQuery<'a> {
pub(crate) fn new(sent_by: Uuid, label: &'a str) -> Self {
Self {
id: None,
sent_by,
label,
}
}

pub(crate) fn execute(&self, conn: &PgConnection) -> Result<Object, Error> {
use crate::schema::agent_stream::dsl::agent_stream;
use diesel::RunQueryDsl;

diesel::insert_into(agent_stream)
.values(self)
.get_result(conn)
}
}
14 changes: 0 additions & 14 deletions src/db/janus_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,6 @@ impl<'a> ListQuery<'a> {
}
}

pub(crate) fn offset(self, offset: i64) -> Self {
Self {
offset: Some(offset),
..self
}
}

pub(crate) fn limit(self, limit: i64) -> Self {
Self {
limit: Some(limit),
..self
}
}

pub(crate) fn execute(&self, conn: &PgConnection) -> Result<Vec<Object>, Error> {
use diesel::prelude::*;

Expand Down
65 changes: 9 additions & 56 deletions src/db/janus_rtc_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ pub(crate) struct Object {
}

impl Object {
#[cfg(test)]
pub(crate) fn handle_id(&self) -> i64 {
self.handle_id
}
Expand All @@ -67,10 +68,12 @@ impl Object {
&self.backend_id
}

#[cfg(test)]
pub(crate) fn label(&self) -> &str {
self.label.as_ref()
}

#[cfg(test)]
pub(crate) fn sent_by(&self) -> &AgentId {
&self.sent_by
}
Expand All @@ -79,37 +82,24 @@ impl Object {
self.time
}

#[cfg(test)]
pub(crate) fn created_at(&self) -> DateTime<Utc> {
self.created_at
}
}

////////////////////////////////////////////////////////////////////////////////

const ACTIVE_SQL: &str = r#"(
lower("janus_rtc_stream"."time") is not null
and upper("janus_rtc_stream"."time") is null
)"#;

pub(crate) struct FindQuery {
id: Option<Uuid>,
rtc_id: Option<Uuid>,
active: Option<bool>,
}

impl FindQuery {
pub(crate) fn new() -> Self {
Self {
id: None,
rtc_id: None,
active: None,
}
}

pub(crate) fn id(self, id: Uuid) -> Self {
Self {
id: Some(id),
..self
}
}

Expand All @@ -120,15 +110,7 @@ impl FindQuery {
}
}

pub(crate) fn active(self, active: bool) -> Self {
Self {
active: Some(active),
..self
}
}

pub(crate) fn execute(&self, conn: &PgConnection) -> Result<Option<Object>, Error> {
use diesel::dsl::sql;
use diesel::prelude::*;

let query = match (self.id, self.rtc_id) {
Expand All @@ -143,18 +125,17 @@ impl FindQuery {
}
};

let query = match self.active {
Some(true) => query.filter(sql(ACTIVE_SQL)),
Some(false) => query.filter(sql(&format!("not {}", ACTIVE_SQL))),
None => query,
};

query.get_result(conn).optional()
}
}

////////////////////////////////////////////////////////////////////////////////

const ACTIVE_SQL: &str = r#"(
lower("janus_rtc_stream"."time") is not null
and upper("janus_rtc_stream"."time") is null
)"#;

pub(crate) struct ListQuery {
room_id: Option<Uuid>,
rtc_id: Option<Uuid>,
Expand Down Expand Up @@ -183,41 +164,13 @@ impl ListQuery {
}
}

pub(crate) fn rtc_id(self, rtc_id: Uuid) -> Self {
Self {
rtc_id: Some(rtc_id),
..self
}
}

pub(crate) fn time(self, time: Time) -> Self {
Self {
time: Some(time),
..self
}
}

pub(crate) fn active(self, active: bool) -> Self {
Self {
active: Some(active),
..self
}
}

pub(crate) fn offset(self, offset: i64) -> Self {
Self {
offset: Some(offset),
..self
}
}

pub(crate) fn limit(self, limit: i64) -> Self {
Self {
limit: Some(limit),
..self
}
}

pub(crate) fn execute(&self, conn: &PgConnection) -> Result<Vec<Object>, Error> {
use diesel::prelude::*;
use diesel::{dsl::sql, sql_types::Tstzrange};
Expand Down
4 changes: 0 additions & 4 deletions src/db/recording.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ pub(crate) struct Object {
}

impl Object {
pub(crate) fn into_tuple(self) -> (Uuid, Status, Option<DateTime<Utc>>, Option<Vec<Segment>>) {
(self.rtc_id, self.status, self.started_at, self.segments)
}

pub(crate) fn started_at(&self) -> &Option<DateTime<Utc>> {
&self.started_at
}
Expand Down
Loading

0 comments on commit faf0447

Please sign in to comment.