Skip to content

Instantly share code, notes, and snippets.

@davisp
Created November 28, 2011 20:08
Show Gist options
  • Save davisp/1401818 to your computer and use it in GitHub Desktop.
Save davisp/1401818 to your computer and use it in GitHub Desktop.
get_priority(Channel, DiskSize, DataSize, Threshold, Dir) ->
MinSize = list_to_integer(smoosh_utils:get(Channel, "min_size", "0")),
MaxSize = case smoosh_utils:get(Channel, "max_size", infinity) of
infinity -> infinity;
Value -> list_to_integer(Value)
end,
ProjectedCapacity = projected_capacity(Dir, DataSize),
MaxCapacity = list_to_integer(
couch_config:get("smoosh", "max_capacity", "90")),
BadSize = DiskSize =< MinSize orelse DiskSize > MaxSize,
NoCapacity = ProjectedCapacity > MaxCapacity,
TooSmall = (DiskSize / DataSize) < Threshold,
if BadSize orelse NoCapacity orelse TooSmall ->
0;
DataSize =:= 0 ->
infinity;
true ->
DiskSize/DataSize
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment