<commit_before>-module(cortex_event_handler).

-export([handle_event/3]).

-include("argo.hrl").
-include("db.hrl").

handle_event(_DT, RK, Payload) ->
    Term = binary_to_term(Payload),
    {ok, HistoryItem} = host_history:cortex_event(Term),
    #host_history{data=Data, host=Host} = HistoryItem,
    Label = proplists:get_value(label, Data),
    case Label of
        AppReachability when AppReachability =:= node_reachable orelse
                             AppReachability =:= node_unreachable ->
            notify_app_change(Host, AppReachability, Data);
        _ ->
            host_history:write(HistoryItem)
    end,

    Value = proplists:get_value(value, Data),
    case Label of
        {running, CommandId} ->
            cortex_command_registrar:recv(CommandId, running, Value);
        {done, CommandId} ->
            cortex_command_registrar:recv(CommandId, done, Value);
        _ ->
            ok
    end,
    ack.

notify_app_change(Host, Reachable, Data) ->
    Value = proplists:get_value(value, Data),
    LastContactTime = proplists:get_value(last_contact_time, Value),
    Node = proplists:get_value(node, Data),
    case ets:lookup(global_comet_pools, {appnav, Host}) of
        [{_, PoolPid}] ->
            PoolPid ! {Host, Reachable, Node, LastContactTime};
        _ ->
            ok
    end.
<commit_msg>ignore some events<commit_after>-module(cortex_event_handler).

-export([handle_event/3]).

-include("argo.hrl").
-include("db.hrl").

handle_event(_DT, RK, Payload) ->
    Term = binary_to_term(Payload),
    {ok, HistoryItem} = host_history:cortex_event(Term),
    #host_history{data=Data, host=Host} = HistoryItem,
    Label = proplists:get_value(label, Data),
    case ignore(Label) of
        true ->
            ok;
        false ->
            case Label of
                AppReachability when AppReachability =:= node_reachable orelse
                                     AppReachability =:= node_unreachable ->
                    notify_app_change(Host, AppReachability, Data);
                _ ->
                    host_history:write(HistoryItem)
            end,

            Value = proplists:get_value(value, Data),
            case Label of
                {running, CommandId} ->
                    cortex_command_registrar:recv(CommandId, running, Value);
                {done, CommandId} ->
                    cortex_command_registrar:recv(CommandId, done, Value);
                _ ->
                    ok
            end
    end,
    ack.

ignore(scheduler_utilization) -> true;
ignore({running, scheduler_utilization}) -> true;
ignore({done, scheduler_utilization}) -> true;
ignore(_) -> false.

notify_app_change(Host, Reachable, Data) ->
    Value = proplists:get_value(value, Data),
    LastContactTime = proplists:get_value(last_contact_time, Value),
    Node = proplists:get_value(node, Data),
    case ets:lookup(global_comet_pools, {appnav, Host}) of
        [{_, PoolPid}] ->
            PoolPid ! {Host, Reachable, Node, LastContactTime};
        _ ->
            ok
    end.

{'fraction_non_alphanumeric': 0.1148936170212766, 'fraction_numerical': 0.0006546644844517185, 'mean_word_length': 2.3508771929824563, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3742538', 'n_tokens_mistral': 965, 'n_tokens_neox': 939, 'n_words': 173}