Fetch data from URL/li>
Split each new line into a list item/li>
Split each line into list items/li>
Find the six digit video id from the URL, it should be the first integer in http paths of:
“c13.adrise.tv/04C0BF/v2/sources/content-owners/”,
“c13.adrise.tv/04C0BF/ads/transcodes/”/li>
Group by Video ID/li>
Get Cache Hit and Misses for each Video/li>
Calculate the Cache Hit Misses
- Sort by video id
import AccessLogApp.CLI, only: [
...
sort_by_field: 2
]
test "Sort by field name" do
list = [
%{:video_id => 9478, "TCP_hit_percentage" => "75%"},
%{:video_id => 234567, "TCP_hit_percentage" => "100%"},
%{:video_id => 9999, "TCP_hit_percentage" => "100%"},
%{:video_id => 004567, "TCP_hit_percentage" => "100%"},
%{:video_id => 123456, "TCP_hit_percentage" => "0%"},
%{:video_id => 009899, "TCP_hit_percentage" => "100%"},
]
result = sort_by_field(list, :video_id)
assert result == [
%{:video_id => 004567, "TCP_hit_percentage" => "100%"},
%{:video_id => 9478, "TCP_hit_percentage" => "75%"},
%{:video_id => 009899, "TCP_hit_percentage" => "100%"},
%{:video_id => 9999, "TCP_hit_percentage" => "100%"},
%{:video_id => 123456, "TCP_hit_percentage" => "0%"},
%{:video_id => 234567, "TCP_hit_percentage" => "100%"}
]
end
def group_by_id(list) do
Enum.group_by(list, fn [video_id, _] ->
[video_id]
end)
end