Comment out read_sql filter, leave it as an example
This commit is contained in:
parent
0a802befb8
commit
1f47ca6523
1 changed files with 9 additions and 5 deletions
14
src/cache.rs
14
src/cache.rs
|
@ -64,7 +64,9 @@ fn establish_connection() -> Result<PgConnection, CacheError> {
|
|||
|
||||
/// Read data from the cache, and return a vector of Cache.
|
||||
fn read_sql(connection: &mut PgConnection) -> QueryResult<Vec<Cache>> {
|
||||
let results = cache.filter(name.eq("Debian")).load::<Cache>(connection)?;
|
||||
let results = cache
|
||||
// .filter(name.eq("Debian"))
|
||||
.load::<Cache>(connection)?;
|
||||
|
||||
Ok(results)
|
||||
}
|
||||
|
@ -82,16 +84,16 @@ fn insert_sql(
|
|||
ip: new_ip,
|
||||
};
|
||||
|
||||
let results = diesel::insert_into(cache::table)
|
||||
let result = diesel::insert_into(cache::table)
|
||||
.values(&cache_element)
|
||||
.get_result(connection)?;
|
||||
|
||||
Ok(results)
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
/// SQL cache function to be called by `get_data` (read) and `api_client` (write).
|
||||
pub fn sql_cache() {
|
||||
let connection = &mut establish_connection().unwrap();
|
||||
pub fn sql_cache() -> Result<(), CacheError> {
|
||||
let connection = &mut establish_connection()?;
|
||||
|
||||
let data = match read_sql(connection) {
|
||||
Ok(data) => data,
|
||||
|
@ -109,4 +111,6 @@ pub fn sql_cache() {
|
|||
}
|
||||
|
||||
let new_cache_element = insert_sql(connection, "Arch", "archlinux.org", "95.217.163.246");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue