diff options
Diffstat (limited to 'src/modules/router/ticker.rs')
| -rw-r--r-- | src/modules/router/ticker.rs | 26 |
1 files changed, 5 insertions, 21 deletions
diff --git a/src/modules/router/ticker.rs b/src/modules/router/ticker.rs index 38b7499..5b44d41 100644 --- a/src/modules/router/ticker.rs +++ b/src/modules/router/ticker.rs @@ -1,26 +1,10 @@ use crate::DATABASE; pub fn module(context: &windmark::context::HookContext) { - let url_path = if context.url.path().is_empty() { - "/" - } else { - context.url.path() - }; + let url_path = + if context.url.path().is_empty() { "/" } else { context.url.path() }; + let mut database = DATABASE.lock().unwrap(); + let current_hits = database.get::<i32>(url_path).unwrap_or(0); - let previous_database = (*DATABASE.lock().unwrap()).get::<i32>(url_path); - - match previous_database { - None => { - (*DATABASE.lock().unwrap()) - .set::<i32>(url_path, &0) - .unwrap(); - } - Some(_) => {} - } - - let new_database = (*DATABASE.lock().unwrap()).get::<i32>(url_path); - - (*DATABASE.lock().unwrap()) - .set(url_path, &(new_database.unwrap() + 1)) - .unwrap(); + database.set(url_path, &(current_hits + 1)).unwrap(); } |