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

Commit

Permalink
renamed class_id to classroom_id
Browse files Browse the repository at this point in the history
  • Loading branch information
khodzha committed Apr 27, 2021
1 parent 2607305 commit b70c9bf
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 39 deletions.
20 changes: 10 additions & 10 deletions docs/src/api/room.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

## Properties

Name | Type | Default | Description
-----------| ---------- | ---------- | ----------------------------------------------------
id | uuid | _required_ | The room identifier.
audience | string | _required_ | The audience of the room.
time | [int, int] | _required_ | Opening and closing timestamps in seconds.
created_at | int | _required_ | Room creation timestamp in seconds.
backend | string | _required_ | Room backend, either `janus` or `none`.
reserve | int | _optional_ | The number of slots for agents reserved on the backend.
tags | json | {} | Arbitrary tags object associated with the room.
class_id | uuid | _optional_ | Dispatcher class identifier which the room belongs to.
Name | Type | Default | Description
------------ | ---------- | ---------- | ----------------------------------------------------
id | uuid | _required_ | The room identifier.
audience | string | _required_ | The audience of the room.
time | [int, int] | _required_ | Opening and closing timestamps in seconds.
created_at | int | _required_ | Room creation timestamp in seconds.
backend | string | _required_ | Room backend, either `janus` or `none`.
reserve | int | _optional_ | The number of slots for agents reserved on the backend.
tags | json | {} | Arbitrary tags object associated with the room.
classroom_id | uuid | _optional_ | Dispatcher class identifier which the room belongs to.


Room can be unbounded, ie its closing timestamp is null.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- This file should undo anything in `up.sql`
ALTER TABLE room RENAME COLUMN classroom_id TO class_id;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- Your SQL goes here
ALTER TABLE room RENAME COLUMN class_id TO classroom_id;
28 changes: 14 additions & 14 deletions src/app/endpoint/room.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub(crate) struct CreateRequest {
rtc_sharing_policy: Option<RtcSharingPolicy>,
reserve: Option<i32>,
tags: Option<JsonValue>,
class_id: Option<Uuid>,
classroom_id: Option<Uuid>,
}

pub(crate) struct CreateHandler;
Expand Down Expand Up @@ -91,8 +91,8 @@ impl RequestHandler for CreateHandler {
q = q.tags(tags);
}

if let Some(class_id) = payload.class_id {
q = q.class_id(class_id);
if let Some(classroom_id) = payload.classroom_id {
q = q.classroom_id(classroom_id);
}

let conn = context.get_conn()?;
Expand Down Expand Up @@ -183,7 +183,7 @@ pub(crate) struct UpdateRequest {
audience: Option<String>,
reserve: Option<Option<i32>>,
tags: Option<JsonValue>,
class_id: Option<Uuid>,
classroom_id: Option<Uuid>,
}
pub(crate) struct UpdateHandler;

Expand Down Expand Up @@ -264,7 +264,7 @@ impl RequestHandler for UpdateHandler {
.audience(payload.audience)
.reserve(payload.reserve)
.tags(payload.tags)
.class_id(payload.class_id)
.classroom_id(payload.classroom_id)
.execute(&conn)?
};

Expand Down Expand Up @@ -493,7 +493,7 @@ mod test {
// Make room.create request.
let mut context = TestContext::new(db.clone(), authz);
let time = (Bound::Unbounded, Bound::Unbounded);
let class_id = Uuid::new_v4();
let classroom_id = Uuid::new_v4();

let payload = CreateRequest {
time: time.clone(),
Expand All @@ -502,7 +502,7 @@ mod test {
rtc_sharing_policy: Some(db::rtc::SharingPolicy::Shared),
reserve: Some(123),
tags: Some(json!({ "foo": "bar" })),
class_id: Some(class_id),
classroom_id: Some(classroom_id),
};

let messages = handle_request::<CreateHandler>(&mut context, &agent, payload)
Expand All @@ -517,7 +517,7 @@ mod test {
assert_eq!(room.rtc_sharing_policy(), db::rtc::SharingPolicy::Shared);
assert_eq!(room.reserve(), Some(123));
assert_eq!(room.tags(), &json!({ "foo": "bar" }));
assert_eq!(room.class_id(), Some(class_id));
assert_eq!(room.classroom_id(), Some(classroom_id));

// Assert notification.
let (room, evp, topic) = find_event::<Room>(messages.as_slice());
Expand All @@ -528,7 +528,7 @@ mod test {
assert_eq!(room.rtc_sharing_policy(), db::rtc::SharingPolicy::Shared);
assert_eq!(room.reserve(), Some(123));
assert_eq!(room.tags(), &json!({ "foo": "bar" }));
assert_eq!(room.class_id(), Some(class_id));
assert_eq!(room.classroom_id(), Some(classroom_id));
});
}

Expand All @@ -546,7 +546,7 @@ mod test {
rtc_sharing_policy: Some(db::rtc::SharingPolicy::Shared),
reserve: None,
tags: None,
class_id: None,
classroom_id: None,
};

let err = handle_request::<CreateHandler>(&mut context, &agent, payload)
Expand Down Expand Up @@ -688,7 +688,7 @@ mod test {

// Make room.update request.
let mut context = TestContext::new(db, authz);
let class_id = Uuid::new_v4();
let classroom_id = Uuid::new_v4();

let time = (
Bound::Included(now + Duration::minutes(50)),
Expand All @@ -701,7 +701,7 @@ mod test {
reserve: Some(Some(123)),
tags: Some(json!({"foo": "bar"})),
audience: None,
class_id: Some(class_id),
classroom_id: Some(classroom_id),
};

let messages = handle_request::<UpdateHandler>(&mut context, &agent, payload)
Expand All @@ -720,7 +720,7 @@ mod test {
);
assert_eq!(resp_room.reserve(), Some(123));
assert_eq!(resp_room.tags(), &json!({"foo": "bar"}));
assert_eq!(resp_room.class_id(), Some(class_id));
assert_eq!(resp_room.classroom_id(), Some(classroom_id));
});
}

Expand Down Expand Up @@ -767,7 +767,7 @@ mod test {
reserve: Some(Some(123)),
tags: Some(json!({"foo": "bar"})),
audience: None,
class_id: None,
classroom_id: None,
};

handle_request::<UpdateHandler>(&mut context, &agent, payload)
Expand Down
4 changes: 2 additions & 2 deletions src/app/endpoint/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ fn upload_config<'a, C: Context>(
fn record_name(recording: &Recording, room: &Room) -> String {
let prefix = match room.rtc_sharing_policy() {
SharingPolicy::Owned => {
if let Some(class_id) = room.class_id() {
format!("{}/", class_id)
if let Some(classroom_id) = room.classroom_id() {
format!("{}/", classroom_id)
} else {
String::from("")
}
Expand Down
27 changes: 15 additions & 12 deletions src/db/room.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type AllColumns = (
room::tags,
room::backend_id,
room::rtc_sharing_policy,
room::class_id,
room::classroom_id,
);

const ALL_COLUMNS: AllColumns = (
Expand All @@ -43,7 +43,7 @@ const ALL_COLUMNS: AllColumns = (
room::tags,
room::backend_id,
room::rtc_sharing_policy,
room::class_id,
room::classroom_id,
);

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -104,7 +104,7 @@ pub(crate) struct Object {
#[serde(skip_serializing_if = "Option::is_none")]
backend_id: Option<AgentId>,
rtc_sharing_policy: RtcSharingPolicy,
class_id: Option<Uuid>,
classroom_id: Option<Uuid>,
}

impl Object {
Expand Down Expand Up @@ -144,8 +144,8 @@ impl Object {
self.rtc_sharing_policy
}

pub(crate) fn class_id(&self) -> Option<Uuid> {
self.class_id
pub(crate) fn classroom_id(&self) -> Option<Uuid> {
self.classroom_id
}
}

Expand Down Expand Up @@ -243,7 +243,7 @@ pub(crate) struct InsertQuery<'a> {
tags: Option<&'a JsonValue>,
backend_id: Option<&'a AgentId>,
rtc_sharing_policy: RtcSharingPolicy,
class_id: Option<Uuid>,
classroom_id: Option<Uuid>,
}

impl<'a> InsertQuery<'a> {
Expand All @@ -256,7 +256,7 @@ impl<'a> InsertQuery<'a> {
tags: None,
backend_id: None,
rtc_sharing_policy,
class_id: None,
classroom_id: None,
}
}

Expand All @@ -282,9 +282,9 @@ impl<'a> InsertQuery<'a> {
}
}

pub(crate) fn class_id(self, class_id: Uuid) -> Self {
pub(crate) fn classroom_id(self, classroom_id: Uuid) -> Self {
Self {
class_id: Some(class_id),
classroom_id: Some(classroom_id),
..self
}
}
Expand All @@ -308,7 +308,7 @@ pub(crate) struct UpdateQuery<'a> {
reserve: Option<Option<i32>>,
tags: Option<JsonValue>,
backend_id: Option<&'a AgentId>,
class_id: Option<Uuid>,
classroom_id: Option<Uuid>,
}

impl<'a> UpdateQuery<'a> {
Expand Down Expand Up @@ -339,8 +339,11 @@ impl<'a> UpdateQuery<'a> {
Self { backend_id, ..self }
}

pub(crate) fn class_id(self, class_id: Option<Uuid>) -> Self {
Self { class_id, ..self }
pub(crate) fn classroom_id(self, classroom_id: Option<Uuid>) -> Self {
Self {
classroom_id,
..self
}
}

pub(crate) fn execute(&self, conn: &PgConnection) -> Result<Object, Error> {
Expand Down
2 changes: 1 addition & 1 deletion src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ table! {
tags -> Json,
backend_id -> Nullable<Agent_id>,
rtc_sharing_policy -> Rtc_sharing_policy,
class_id -> Nullable<Uuid>,
classroom_id -> Nullable<Uuid>,
}
}

Expand Down

0 comments on commit b70c9bf

Please sign in to comment.