mirror of
https://github.com/YGGverse/rssto.git
synced 2026-03-31 09:05:29 +00:00
rename table
This commit is contained in:
parent
7b9fac8d3a
commit
e26236a591
3 changed files with 23 additions and 23 deletions
|
|
@ -187,7 +187,7 @@ fn crawl(db: &Mysql, channel_config: &config::Channel) -> Result<()> {
|
|||
},
|
||||
};
|
||||
assert!(
|
||||
db.contents_by_channel_item_id_source_id(channel_item_id, None, Some(1))?
|
||||
db.contents_by_channel_item_id_provider_id(channel_item_id, None, Some(1))?
|
||||
.is_empty()
|
||||
);
|
||||
let _content_id = db.insert_content(channel_item_id, None, title, description)?;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
-- MySQL Script generated by MySQL Workbench
|
||||
-- Wed 07 Jan 2026 04:18:03 PM EET
|
||||
-- Thu 08 Jan 2026 12:40:45 AM EET
|
||||
-- Model: New Model Version: 1.0
|
||||
-- MySQL Workbench Forward Engineering
|
||||
|
||||
|
|
@ -51,12 +51,12 @@ ENGINE = InnoDB;
|
|||
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `rssto`.`source`
|
||||
-- Table `rssto`.`provider`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `rssto`.`source` (
|
||||
`source_id` INT NOT NULL AUTO_INCREMENT,
|
||||
CREATE TABLE IF NOT EXISTS `rssto`.`provider` (
|
||||
`provider_id` INT NOT NULL AUTO_INCREMENT,
|
||||
`name` VARCHAR(255) NOT NULL,
|
||||
PRIMARY KEY (`source_id`),
|
||||
PRIMARY KEY (`provider_id`),
|
||||
UNIQUE INDEX `name_UNIQUE` (`name` ASC) VISIBLE)
|
||||
ENGINE = InnoDB;
|
||||
|
||||
|
|
@ -67,21 +67,21 @@ ENGINE = InnoDB;
|
|||
CREATE TABLE IF NOT EXISTS `rssto`.`content` (
|
||||
`content_id` BIGINT NOT NULL AUTO_INCREMENT,
|
||||
`channel_item_id` INT NOT NULL,
|
||||
`source_id` INT NULL,
|
||||
`provider_id` INT NULL,
|
||||
`title` VARCHAR(255) NOT NULL,
|
||||
`description` LONGTEXT NOT NULL,
|
||||
PRIMARY KEY (`content_id`),
|
||||
INDEX `fk_content_channel_item_idx` (`channel_item_id` ASC) VISIBLE,
|
||||
INDEX `fk_content_source_idx` (`source_id` ASC) VISIBLE,
|
||||
UNIQUE INDEX `UNIQUE` (`channel_item_id` ASC, `source_id` ASC) VISIBLE,
|
||||
INDEX `fk_content_provider_idx` (`provider_id` ASC) VISIBLE,
|
||||
UNIQUE INDEX `UNIQUE` (`channel_item_id` ASC, `provider_id` ASC) VISIBLE,
|
||||
CONSTRAINT `fk_content_channel_item`
|
||||
FOREIGN KEY (`channel_item_id`)
|
||||
REFERENCES `rssto`.`channel_item` (`channel_item_id`)
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION,
|
||||
CONSTRAINT `fk_content_source`
|
||||
FOREIGN KEY (`source_id`)
|
||||
REFERENCES `rssto`.`source` (`source_id`)
|
||||
CONSTRAINT `fk_content_provider`
|
||||
FOREIGN KEY (`provider_id`)
|
||||
REFERENCES `rssto`.`provider` (`provider_id`)
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION)
|
||||
ENGINE = InnoDB;
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ impl Mysql {
|
|||
self.pool.get_conn()?.exec_first(
|
||||
"SELECT `content_id`,
|
||||
`channel_item_id`,
|
||||
`source_id`,
|
||||
`provider_id`,
|
||||
`title`,
|
||||
`description` FROM `content` WHERE `content_id` = ?",
|
||||
(content_id,),
|
||||
|
|
@ -118,43 +118,43 @@ impl Mysql {
|
|||
self.pool.get_conn()?.query(format!(
|
||||
"SELECT `content_id`,
|
||||
`channel_item_id`,
|
||||
`source_id`,
|
||||
`provider_id`,
|
||||
`title`,
|
||||
`description` FROM `content` ORDER BY `content_id` {sort} LIMIT {}",
|
||||
limit.unwrap_or(DEFAULT_LIMIT)
|
||||
))
|
||||
}
|
||||
|
||||
pub fn contents_by_channel_item_id_source_id(
|
||||
pub fn contents_by_channel_item_id_provider_id(
|
||||
&self,
|
||||
channel_item_id: u64,
|
||||
source_id: Option<u64>,
|
||||
provider_id: Option<u64>,
|
||||
limit: Option<usize>,
|
||||
) -> Result<Vec<Content>, Error> {
|
||||
self.pool.get_conn()?.exec(
|
||||
format!(
|
||||
"SELECT `content_id`,
|
||||
`channel_item_id`,
|
||||
`source_id`,
|
||||
`provider_id`,
|
||||
`title`,
|
||||
`description` FROM `content` WHERE `channel_item_id` = ? AND `source_id` = ? LIMIT {}",
|
||||
`description` FROM `content` WHERE `channel_item_id` = ? AND `provider_id` = ? LIMIT {}",
|
||||
limit.unwrap_or(DEFAULT_LIMIT)
|
||||
),
|
||||
(channel_item_id, source_id),
|
||||
(channel_item_id, provider_id),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn insert_content(
|
||||
&self,
|
||||
channel_item_id: u64,
|
||||
source_id: Option<u64>,
|
||||
provider_id: Option<u64>,
|
||||
title: String,
|
||||
description: String,
|
||||
) -> Result<u64, Error> {
|
||||
let mut c = self.pool.get_conn()?;
|
||||
c.exec_drop(
|
||||
"INSERT INTO `content` SET `channel_item_id` = ?, `source_id` = ?, `title` = ?, `description` = ?",
|
||||
(channel_item_id, source_id, title, description ),
|
||||
"INSERT INTO `content` SET `channel_item_id` = ?, `provider_id` = ?, `title` = ?, `description` = ?",
|
||||
(channel_item_id, provider_id, title, description ),
|
||||
)?;
|
||||
Ok(c.last_insert_id())
|
||||
}
|
||||
|
|
@ -183,7 +183,7 @@ pub struct Content {
|
|||
pub channel_item_id: u64,
|
||||
/// None if the original `title` and `description` values
|
||||
/// parsed from the channel item on crawl
|
||||
pub source_id: Option<u64>,
|
||||
pub provider_id: Option<u64>,
|
||||
pub title: String,
|
||||
pub description: String,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue