jaydoane commented on a change in pull request #2: Avoid using `erlang:now/0` URL: https://github.com/apache/couchdb-smoosh/pull/2#discussion_r259474872
########## File path: src/smoosh_server.erl ########## @@ -265,8 +265,10 @@ find_channel(Tab, [Channel|Rest], Object) -> Pid = channel_pid(Tab, Channel), LastUpdated = smoosh_channel:last_updated(Pid, Object), Staleness = 6.0e7 * list_to_integer(config:get("smoosh", "staleness", "5")), + Now = erlang:monotonic_time(), case LastUpdated =:= false orelse - timer:now_diff(now(), LastUpdated) > Staleness of + erlang:convert_time_unit( + Now - LastUpdated, native, microsecond) > Staleness of Review comment: How do we know at a glance that`Staleness` has units of `microsecond`? Maybe while we're updating this code, we could eliminate some magic. The README says: "**staleness** The number of minutes that the (expensive) priority calculation can be stale for before it is recalculated. Defaults to 5." So I'd recommend we do something like: ``` -define(MICROSECONDS_PER_MINUTE, 60 * 1.0e6). ``` And then write line 267 as ``` Staleness = ?MICROSECONDS_PER_MINUTE * config:get_integer( "smoosh", "staleness", "5"), ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services