mirror of
https://github.com/YGGverse/rssto.git
synced 2026-03-31 09:05:29 +00:00
apply missed db updates
This commit is contained in:
parent
2b804d8915
commit
1bee7daf77
5 changed files with 24 additions and 42 deletions
|
|
@ -201,12 +201,12 @@ fn crawl(tx: &mut mysql::Transaction, channel_config: &config::Channel) -> Resul
|
||||||
image_id
|
image_id
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let content_image_id =
|
let channel_item_content_image_id =
|
||||||
tx.insert_content_image(channel_item_content_id, image_id)?;
|
tx.insert_channel_item_content_image(channel_item_content_id, image_id)?;
|
||||||
debug!("Add content image relationship #{content_image_id}");
|
debug!("Add content image relationship #{channel_item_content_image_id}");
|
||||||
let uri = format!("/image/{image_id}");
|
let uri = format!("/image/{image_id}");
|
||||||
tx.replace_channel_item_content_description(
|
tx.replace_channel_item_content_description(
|
||||||
channel_item_content_id,
|
channel_item_content_description_id,
|
||||||
src,
|
src,
|
||||||
&uri,
|
&uri,
|
||||||
)?;
|
)?;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
-- MySQL Script generated by MySQL Workbench
|
-- MySQL Script generated by MySQL Workbench
|
||||||
-- нд, 11-січ-2026 20:33:40 +0200
|
-- нд, 11-січ-2026 21:01:10 +0200
|
||||||
-- Model: New Model Version: 1.0
|
-- Model: New Model Version: 1.0
|
||||||
-- MySQL Workbench Forward Engineering
|
-- MySQL Workbench Forward Engineering
|
||||||
|
|
||||||
|
|
@ -101,13 +101,13 @@ ENGINE = InnoDB;
|
||||||
-- -----------------------------------------------------
|
-- -----------------------------------------------------
|
||||||
CREATE TABLE IF NOT EXISTS `rssto`.`channel_item_content_image` (
|
CREATE TABLE IF NOT EXISTS `rssto`.`channel_item_content_image` (
|
||||||
`channel_item_content_image_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
`channel_item_content_image_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||||
`content_channel_item_content_id` BIGINT UNSIGNED NOT NULL,
|
`channel_item_content_id` BIGINT UNSIGNED NOT NULL,
|
||||||
`image_id` BIGINT UNSIGNED NOT NULL,
|
`image_id` BIGINT UNSIGNED NOT NULL,
|
||||||
PRIMARY KEY (`channel_item_content_image_id`),
|
PRIMARY KEY (`channel_item_content_image_id`),
|
||||||
INDEX `fk_channel_item_content_image_channel_item_content_idx` (`content_channel_item_content_id` ASC) VISIBLE,
|
INDEX `fk_channel_item_content_image_channel_item_content_idx` (`channel_item_content_id` ASC) VISIBLE,
|
||||||
INDEX `fk_channel_item_content_image_image_idx` (`image_id` ASC) VISIBLE,
|
INDEX `fk_channel_item_content_image_image_idx` (`image_id` ASC) VISIBLE,
|
||||||
CONSTRAINT `fk_channel_item_content_image_channel_item_content`
|
CONSTRAINT `fk_channel_item_content_image_channel_item_content`
|
||||||
FOREIGN KEY (`content_channel_item_content_id`)
|
FOREIGN KEY (`channel_item_content_id`)
|
||||||
REFERENCES `rssto`.`channel_item_content` (`channel_item_content_id`)
|
REFERENCES `rssto`.`channel_item_content` (`channel_item_content_id`)
|
||||||
ON DELETE NO ACTION
|
ON DELETE NO ACTION
|
||||||
ON UPDATE NO ACTION,
|
ON UPDATE NO ACTION,
|
||||||
|
|
|
||||||
|
|
@ -114,22 +114,10 @@ impl Connection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn content_image(&mut self, content_image_id: u64) -> Result<Option<ContentImage>, Error> {
|
|
||||||
self.conn.exec_first(
|
|
||||||
"SELECT `content_image_id`,
|
|
||||||
`content_id`,
|
|
||||||
`image_id`,
|
|
||||||
`data`,
|
|
||||||
`source` FROM `content_image`
|
|
||||||
JOIN `image` ON (`image`.`image_id` = `content_image`.`image_id`)
|
|
||||||
WHERE `content_image_id` = ? LIMIT 1",
|
|
||||||
(content_image_id,),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn image(&mut self, image_id: u64) -> Result<Option<Image>, Error> {
|
pub fn image(&mut self, image_id: u64) -> Result<Option<Image>, Error> {
|
||||||
self.conn.exec_first(
|
self.conn.exec_first(
|
||||||
"SELECT `image_id`,
|
"SELECT `image_id`,
|
||||||
|
`provider_id`,
|
||||||
`sha256`,
|
`sha256`,
|
||||||
`src`,
|
`src`,
|
||||||
`url`,
|
`url`,
|
||||||
|
|
|
||||||
|
|
@ -59,17 +59,6 @@ pub struct Image {
|
||||||
pub data: Vec<u8>,
|
pub data: Vec<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Includes joined `image` table members
|
|
||||||
#[derive(Debug, PartialEq, Eq, FromRow)]
|
|
||||||
pub struct ContentImage {
|
|
||||||
pub content_image_id: u64,
|
|
||||||
pub content_id: u64,
|
|
||||||
pub image_id: u64,
|
|
||||||
// Image members (JOIN)
|
|
||||||
pub data: Vec<u8>,
|
|
||||||
pub source: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub enum Sort {
|
pub enum Sort {
|
||||||
Asc,
|
Asc,
|
||||||
Desc,
|
Desc,
|
||||||
|
|
|
||||||
|
|
@ -106,20 +106,20 @@ impl Transaction {
|
||||||
provider_id: u64,
|
provider_id: u64,
|
||||||
) -> Result<Vec<ChannelItemContentDescription>, Error> {
|
) -> Result<Vec<ChannelItemContentDescription>, Error> {
|
||||||
self.tx.exec(
|
self.tx.exec(
|
||||||
"SELECT `t1`.`content_id`,
|
"SELECT `t1`.`channel_item_content_description_id`,
|
||||||
`t1`.`channel_item_id`,
|
`t1`.`channel_item_content_id`,
|
||||||
`t1`.`provider_id`,
|
`t1`.`provider_id`,
|
||||||
`t1`.`title`,
|
`t1`.`title`,
|
||||||
`t1`.`description`
|
`t1`.`description`
|
||||||
FROM `channel_item_content_description` AS `t1`
|
FROM `channel_item_content_description` AS `t1`
|
||||||
WHERE `t1`.`provider_id` IS NULL AND NOT EXISTS (
|
WHERE `t1`.`provider_id` IS NULL AND NOT EXISTS (
|
||||||
SELECT NULL FROM `channel_item_content_description` AS `t2`
|
SELECT NULL FROM `channel_item_content_description` AS `t2`
|
||||||
WHERE `t2`.`channel_item_id` = `t1`.`channel_item_id`
|
WHERE `t2`.`channel_item_content_description_id` = `t1`.`channel_item_content_description_id`
|
||||||
AND `t2`.`provider_id` = ? LIMIT 1
|
AND `t2`.`provider_id` = ? LIMIT 1
|
||||||
)",
|
)",
|
||||||
(provider_id,),
|
(provider_id,),
|
||||||
)
|
)
|
||||||
}
|
} // @TODO upgrade to the latest version
|
||||||
|
|
||||||
pub fn insert_channel_item_content(&mut self, channel_item_id: u64) -> Result<u64, Error> {
|
pub fn insert_channel_item_content(&mut self, channel_item_id: u64) -> Result<u64, Error> {
|
||||||
self.tx.exec_drop(
|
self.tx.exec_drop(
|
||||||
|
|
@ -148,21 +148,26 @@ impl Transaction {
|
||||||
|
|
||||||
pub fn replace_channel_item_content_description(
|
pub fn replace_channel_item_content_description(
|
||||||
&mut self,
|
&mut self,
|
||||||
content_id: u64,
|
channel_item_content_description_id: u64,
|
||||||
from: &str,
|
from: &str,
|
||||||
to: &str,
|
to: &str,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
self.tx.exec_drop(
|
self.tx.exec_drop(
|
||||||
"UPDATE `channel_item_content_description`
|
"UPDATE `channel_item_content_description`
|
||||||
SET `description` = REPLACE(`description`, ?, ?) WHERE`content_id` = ?",
|
SET `description` = REPLACE(`description`, ?, ?)
|
||||||
(from, to, content_id),
|
WHERE `channel_item_content_description_id` = ?",
|
||||||
|
(from, to, channel_item_content_description_id),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn insert_content_image(&mut self, content_id: u64, image_id: u64) -> Result<u64, Error> {
|
pub fn insert_channel_item_content_image(
|
||||||
|
&mut self,
|
||||||
|
channel_item_content_id: u64,
|
||||||
|
image_id: u64,
|
||||||
|
) -> Result<u64, Error> {
|
||||||
self.tx.exec_drop(
|
self.tx.exec_drop(
|
||||||
"INSERT INTO `content_image` SET `content_id` = ?, `image_id` = ?",
|
"INSERT INTO `channel_item_content_image` SET `channel_item_content_id` = ?, `image_id` = ?",
|
||||||
(content_id, image_id),
|
(channel_item_content_id, image_id),
|
||||||
)?;
|
)?;
|
||||||
Ok(self.tx.last_insert_id().unwrap())
|
Ok(self.tx.last_insert_id().unwrap())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue