diff --git a/crates/http/src/main.rs b/crates/http/src/main.rs index aa5e4e6..89fe477 100644 --- a/crates/http/src/main.rs +++ b/crates/http/src/main.rs @@ -77,6 +77,7 @@ fn index( global.provider_id, search, Sort::Desc, + page.map(|p| p - 1 * global.list_limit), Some(global.list_limit) ).map_err(|e| { error!("Could not get contents: `{e}`"); @@ -175,7 +176,13 @@ fn rss( Status::InternalServerError })?; for content in conn - .contents_by_provider_id(global.provider_id, search, Sort::Desc, Some(20)) // @TODO + .contents_by_provider_id( + global.provider_id, + search, + Sort::Desc, + None, + Some(global.list_limit), + ) .map_err(|e| { error!("Could not load channel item contents: `{e}`"); Status::InternalServerError diff --git a/crates/mysql/src/connection.rs b/crates/mysql/src/connection.rs index 6b6bda6..d9617d1 100644 --- a/crates/mysql/src/connection.rs +++ b/crates/mysql/src/connection.rs @@ -54,6 +54,7 @@ impl Connection { provider_id: Option, keyword: Option<&str>, sort: Sort, + start: Option, limit: Option, ) -> Result, Error> { self.conn.exec(format!( @@ -61,7 +62,8 @@ impl Connection { `channel_item_id`, `provider_id`, `title`, - `description` FROM `content` WHERE `provider_id` <=> ? AND `title` LIKE ? ORDER BY `content_id` {sort} LIMIT {}", + `description` FROM `content` WHERE `provider_id` <=> ? AND `title` LIKE ? ORDER BY `content_id` {sort} LIMIT {},{}", + start.unwrap_or(0), limit.unwrap_or(DEFAULT_LIMIT) ), (provider_id, like(keyword), ))