Skip to content

Commit

Permalink
fly:db
Browse files Browse the repository at this point in the history
  • Loading branch information
cn-kali-team committed Apr 10, 2024
1 parent 210aa04 commit 57feaeb
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 8 deletions.
7 changes: 4 additions & 3 deletions nvd-model/src/cve/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ impl QueryCve {
if let Some(order) = &self.order {
let o: Box<dyn BoxableExpression<cves::table, _, SqlType = NotSelectable>> = match order.order
{
OrderBy::Asc => Box::new(cves::id.asc()),
OrderBy::Desc => Box::new(cves::id.desc()),
OrderBy::Asc => Box::new(cves::created_at.asc()),
OrderBy::Desc => Box::new(cves::created_at.desc()),
};
query = query.order_by(o);
} else {
query = query.order_by(cves::id.desc());
query = query.order_by(cves::created_at.desc());
}
Ok(query)
}
Expand Down Expand Up @@ -87,6 +87,7 @@ impl Cve {
.set((
cves::description.eq(&c.description),
cves::translated.eq(&c.translated),
cves::updated_at.eq(&c.updated_at),
))
.execute(conn)
.unwrap_or_default();
Expand Down
2 changes: 1 addition & 1 deletion nvd-model/src/cve/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ use utoipa::{IntoParams, ToSchema};
#[cfg(feature = "yew")]
use yew::Properties;

use crate::common::order::{order_serde, OrderMap};
#[cfg(feature = "db")]
use crate::schema::cves;
use crate::types::AnyValue;
use crate::common::order::{OrderMap, order_serde};

#[cfg(feature = "db")]
pub mod db;
Expand Down
2 changes: 1 addition & 1 deletion nvd-model/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use diesel::{r2d2, r2d2::ConnectionManager, MysqlConnection};
// #[cfg(all(feature = "db", feature = "yew"))]
// compile_error!("feature \"db\" and feature \"yew\" cannot be enabled at the same time");

pub mod common;
pub mod cve;
pub mod cve_knowledge_base;
pub mod cve_product;
Expand All @@ -19,7 +20,6 @@ pub mod product;
pub mod schema;
pub mod types;
pub mod vendor;
pub mod common;

#[cfg(feature = "db")]
pub type DB = diesel::mysql::Mysql;
Expand Down
2 changes: 1 addition & 1 deletion nvd-yew/src/component/cpe_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl Component for CPEQuery {
},
part: if part.is_empty() { None } else { Some(part) },
size: query.size,
page: query.page,
page: None,
official: None,
})
})
Expand Down
2 changes: 1 addition & 1 deletion nvd-yew/src/component/cve_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl Component for CVEQuery {
Some(severity)
},
size: query.size,
page: query.page,
page: None,
order: None,
})
})
Expand Down
2 changes: 1 addition & 1 deletion nvd-yew/src/component/kb_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl Component for KBQuery {
Some(source)
},
size: query.size,
page: query.page,
page: None,
verified: None,
path: None,
types: None,
Expand Down

0 comments on commit 57feaeb

Please sign in to comment.