Remove _db in func names of db interactions
This commit is contained in:
19
src/db.rs
19
src/db.rs
@@ -93,7 +93,7 @@ impl DBTable for ParsedPage {
|
||||
";
|
||||
}
|
||||
impl ParsedPage {
|
||||
pub fn lookup_db(conn: &Connection, timestamp: DateTime<Utc>) -> Option<Self> {
|
||||
pub fn lookup(conn: &Connection, timestamp: DateTime<Utc>) -> Option<Self> {
|
||||
let mut stmt = conn
|
||||
.prepare(&format!(
|
||||
"SELECT * FROM {} WHERE timestamp = ?",
|
||||
@@ -110,7 +110,7 @@ impl ParsedPage {
|
||||
.ok()
|
||||
}
|
||||
|
||||
pub fn add_or_update_db(&self, conn: &Connection) {
|
||||
pub fn add_or_update(&self, conn: &Connection) {
|
||||
let _ = conn
|
||||
.execute(
|
||||
&format!(
|
||||
@@ -148,7 +148,7 @@ impl DBTable for ParsedStorage {
|
||||
";
|
||||
}
|
||||
impl ParsedStorage {
|
||||
pub fn lookup_db(conn: &Connection, item: i64) -> Vec<ParsedStorage> {
|
||||
pub fn lookup(conn: &Connection, item: i64) -> Vec<ParsedStorage> {
|
||||
let mut stmt = conn
|
||||
.prepare(&format!("SELECT * FROM {} WHERE id = ?", Self::TABLE_NAME))
|
||||
.ok()
|
||||
@@ -173,7 +173,7 @@ impl ParsedStorage {
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn add_or_update_db(&self, conn: &Connection) {
|
||||
pub fn add_or_update(&self, conn: &Connection) {
|
||||
let _ = conn.execute(&format!("
|
||||
INSERT OR REPLACE INTO {}
|
||||
(item, total_gigabytes, quantity, sizes_gigabytes, parse_engine, need_description_check)
|
||||
@@ -440,18 +440,15 @@ mod tests {
|
||||
parse_engine: 9,
|
||||
needed_description_check: true,
|
||||
};
|
||||
parsed.add_or_update_db(&db);
|
||||
assert_eq!(ParsedStorage::lookup_db(&db, listing.id), vec![parsed]);
|
||||
parsed.add_or_update(&db);
|
||||
assert_eq!(ParsedStorage::lookup(&db, listing.id), vec![parsed]);
|
||||
|
||||
let page = ParsedPage {
|
||||
category: "ssd".to_owned(),
|
||||
timestamp: std::time::SystemTime::now().into(),
|
||||
};
|
||||
page.add_or_update_db(&db);
|
||||
assert_eq!(
|
||||
ParsedPage::lookup_db(&db, page.timestamp),
|
||||
Some(page.clone())
|
||||
);
|
||||
page.add_or_update(&db);
|
||||
assert_eq!(ParsedPage::lookup(&db, page.timestamp), Some(page.clone()));
|
||||
|
||||
let apperance = ItemAppearances {
|
||||
item: listing.item_id,
|
||||
|
Reference in New Issue
Block a user