Commit 1b54b707 authored by Ricardo J. Mendez's avatar Ricardo J. Mendez

Not tracking time for non-HTTP URLs, deprioritizing them
parent 9b163a95
(:require [relevance.utils :refer [url-key host-key hostname]]
(:require [relevance.utils :refer [url-key is-http? host-key hostname]]
[khroma.log :as console]))
......@@ -48,6 +48,7 @@
:time 0
:ts 0})
track? (and (not= 0 id)
(is-http? url)
(not (contains? ignore-set (hostname url)))
(pos? time))
new-item (assoc url-item :time (+ (:time url-item) time)
......@@ -64,13 +65,15 @@
timestamps the record with the timestamp received, and adds the favIconUrl of
the tab as the one for the entire site."
[site-times tab time timestamp & {:keys [ignore-set]}]
(let [host (hostname (or (:url tab) ""))
(let [url (:url tab)
host (hostname (or url ""))
id (host-key host)
site-item (or (get site-times id)
{:host host
:time 0
:ts 0})
track? (and (not= 0 id)
(is-http? url)
(not (contains? ignore-set host))
(pos? time))
new-item (assoc site-item :time (+ (:time site-item) time)
......@@ -158,6 +158,21 @@
(is (= 7 (count result)) "We should not have added any elements")
(is (= result (:url-times test-db)))
(testing "Non-http URLs aren't tracked"
(let [tab {:url "file:///Users/my-user/the-file.html"
:title "Numergent limited"}
ts 1445964037799
result (data/track-url-time (:url-times test-db)
tab-key (utils/url-key "file:///Users/my-user/the-file.html")
item (get result tab-key)]
(is result)
(is (= 7 (count result)) "We shouldn't have added an element")
(is (nil? item) "We should not have the URL on our list")
(is (= result (:url-times test-db)) "Database should not have been altered")
(testing "Add time to a new tab on an empty set"
(let [tab {:url ""
......@@ -117,6 +117,7 @@
"" true
"chrome://extensions/?id=okhigbflgnbihoiokilagelkalkcigfp" false
"view-source:http://localhost:4000/opensource/" false
"file:///Users/myuser/file.html" false
"http" false
"" false
nil false
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment