mirror of
https://github.com/YGGverse/rssto.git
synced 2026-04-02 10:05:32 +00:00
implement local image features
This commit is contained in:
parent
3e94399ccb
commit
e86b241ee6
6 changed files with 52 additions and 21 deletions
|
|
@ -80,11 +80,15 @@ impl Connection {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn images(&mut self, limit: Option<usize>) -> Result<Vec<Image>, Error> {
|
||||
self.conn.query(format!(
|
||||
"SELECT `image_id`, `source`, `data` FROM `image` LIMIT {}",
|
||||
limit.unwrap_or(DEFAULT_LIMIT)
|
||||
))
|
||||
pub fn image(&mut self, image_id: u64) -> Result<Option<Image>, Error> {
|
||||
self.conn.exec_first(
|
||||
"SELECT `image_id`,
|
||||
`sha256`,
|
||||
`src`,
|
||||
`url`,
|
||||
`data` FROM `image` WHERE `image_id` = ?",
|
||||
(image_id,),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn provider_id_by_name(&mut self, name: &str) -> Result<Option<u64>, Error> {
|
||||
|
|
|
|||
|
|
@ -107,6 +107,19 @@ impl Transaction {
|
|||
Ok(self.tx.last_insert_id().unwrap())
|
||||
}
|
||||
|
||||
pub fn replace_content_description(
|
||||
&mut self,
|
||||
content_id: u64,
|
||||
from: &str,
|
||||
to: &str,
|
||||
) -> Result<(), Error> {
|
||||
self.tx.exec_drop(
|
||||
"UPDATE `content` SET `description` = REPLACE(`description`, ?, ?)
|
||||
WHERE`content_id` = ?",
|
||||
(from, to, content_id),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn insert_content_image(&mut self, content_id: u64, image_id: u64) -> Result<u64, Error> {
|
||||
self.tx.exec_drop(
|
||||
"INSERT INTO `content_image` SET `content_id` = ?, `image_id` = ?",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue