diff --git a/README.md b/README.md
index 1b4f31d..9856e10 100644
--- a/README.md
+++ b/README.md
@@ -10,10 +10,21 @@ SQL checking macros, so your DB needs to have the tables to allow the SQL checks
## How does it work?
-If you wish to use this on your webpage, just add the following lines to the page you want a counter
-on:
+If you wish to use this on your webpage, you need to add a couple lines. First, a "tracking pixel"
+that registers the current page's view:
+
+``` html
+
+```
+
+Then, some javascript to retrieve the hit counts:
+
+``` html
+help I don't know how to javascript, we need to get http://localhost:5000/hits/all (or 'day' or
+'week'), and that will return the number of recorded hits for this page for that time period.
+```
+
-TODO!!!
It uses the `referer` header to get the page it was called from, and uses that as the key for
counting the hit.
diff --git a/src/main.rs b/src/main.rs
index 1b2aa75..793afe2 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -22,7 +22,7 @@ async fn main() {
let pool = db().await;
let app = Router::new()
- .route("/hit", get(count_hit))
+ .route("/hit", get(register_hit))
.route("/hits/:period", get(get_hits))
.with_state(pool.clone())
.into_make_service();
@@ -35,7 +35,7 @@ async fn main() {
pool.close().await;
}
-async fn count_hit(State(db): State, headers: HeaderMap) -> String {
+async fn register_hit(State(db): State, headers: HeaderMap) -> String {
let now = chrono::Utc::now();
let referer = headers.get(REFERER);
let page = if let Some(referer) = referer {
@@ -109,7 +109,7 @@ async fn get_period_hits(db: &SqlitePool, page: &str, when: &str) -> i32 {
)
.fetch_one(db)
.await
- .unwrap_or(1)
+ .unwrap_or(0)
}
//-************************************************************************