<commit_before>-module(mover_status).

-export([org_by_name/1,
         migration_time/1,
         summarize_orgs/0,
         summarize_time/0,
         read_only_orgs/0,
         active_orgs/0,
         error_orgs/0,
         error_nodes/0,
         set_orgs_migrated/1,
         reset_orgs/1]).

-include("mover.hrl").

org_by_name(Name) ->
    Spec = ?wildcard_org_spec#org{name = Name},
    ?fix_table(all_orgs, dets:match_object(all_orgs, Spec)).

set_orgs_migrated(Orgs) ->
    ZeroTime = [{start, os:timestamp()}, {stop, os:timestamp()}],
    Orgs1 = [ Org#org{migrated = true, time = ZeroTime} || Org <- Orgs ],
    [ dets:insert(all_orgs, Org) || Org <- Orgs1 ].

reset_orgs(Orgs) ->
    [ dets:insert(all_orgs, Org#org{active = false,
                                    migrated = false,
                                    error = false,
                                    worker = undefined})
      || Org <- Orgs].

migration_time(#org{}=Org) ->
    [{total, time_diff(Org#org.time, start, stop)},<commit_msg>Add time reset to reset<commit_after>-module(mover_status).

-export([org_by_name/1,
         migration_time/1,
         summarize_orgs/0,
         summarize_time/0,
         read_only_orgs/0,
         active_orgs/0,
         error_orgs/0,
         error_nodes/0,
         set_orgs_migrated/1,
         reset_orgs/1]).

-include("mover.hrl").

org_by_name(Name) ->
    Spec = ?wildcard_org_spec#org{name = Name},
    ?fix_table(all_orgs, dets:match_object(all_orgs, Spec)).

set_orgs_migrated(Orgs) ->
    ZeroTime = [{start, os:timestamp()}, {stop, os:timestamp()}],
    Orgs1 = [ Org#org{migrated = true, time = ZeroTime} || Org <- Orgs ],
    [ dets:insert(all_orgs, Org) || Org <- Orgs1 ].

reset_orgs(Orgs) ->
    [ dets:insert(all_orgs, Org#org{active = false,
                                    migrated = false,
                                    error = false,
                                    worker = undefined,
                                    time = []})
      || Org <- Orgs].

migration_time(#org{}=Org) ->
    [{total, time_diff(Org#org.time, start, stop)},
{'fraction_non_alphanumeric': 0.14346793349168646, 'fraction_numerical': 0.01140142517814727, 'mean_word_length': 1.9578651685393258, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '74273', 'n_tokens_mistral': 763, 'n_tokens_neox': 755, 'n_words': 110}