<commit_before>-module(bootstrap).
-export([start/1]).

start([AdminPassword]) ->
    io:format("Bootstrapping Yxa on node ~p~n", [node()]),
    ok = mnesia:create_schema([node()]),
    ok = mnesia:start(),
    io:format("Creating tables on this Mnesia node (~p)~n", [node()]),
    phone:create([node()]),
    database_regexproute:create([node()]),
    database_forward:create([node()]),
    database_call:create([node()]),
    io:format("Creating admin-user~n"),
    phone:insert_user("admin", AdminPassword, [admin], []).<commit_msg>show progress through a series of io:format()'s<commit_after>-module(bootstrap).
-export([start/1]).

start([AdminPassword]) ->
    io:format("Bootstrapping Yxa on node ~p :~n", [node()]),
    ok = create_schema(node()),
    ok = mnesia:start(),

    io:format("* Creating tables on this Mnesia node (~p)~n", [node()]),
    init_db_module([phone,
		    database_regexproute,
		    database_forward,
		    database_call
		   ], node()),

    io:format("* Updating any pre-existing table definitions~n"),
    ok = table_update:update(),

    io:format("* Creating admin-user~n"),
    phone:insert_user("admin", AdminPassword, [admin], []),

    ok = mnesia:stop(),
    io:format("~nBootstrapping complete.~n~n").

create_schema(Node) ->
    case mnesia:create_schema([Node]) of
	ok ->
	    io:format("* Created Mnesia schema on node ~p~n", [Node]);
	{error, {Node, {already_exists, Node}}} ->
	    io:format("* Mnesia schema already existed on node ~p~n", [Node]);
	E ->
	    io:format("~nFailed creating Mnesia schema on node ~p :~n~p---~nExiting.",
		      [Node, E]),
	    erlang:halt(1)
    end,
    ok.

init_db_module([H | T], Node) ->
    io:format("  + Creating table '~p'~n", [H]),
    H:create([Node]),
    init_db_module(T, Node);
init_db_module([], _Node) ->
    ok.
{'fraction_non_alphanumeric': 0.19602429596907786, 'fraction_numerical': 0.0016565433462175593, 'mean_word_length': 4.047353760445683, 'pattern_counts': {'":': 0, '<': 3, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5672757', 'n_tokens_mistral': 647, 'n_tokens_neox': 619, 'n_words': 136}