<commit_before>#! /usr/bin/env escript
%%! -sname rpg_battlemap_dev
-mode(compile).

%% @doc Create the mnesia tables, or compile the boss_db models.  Update
%% the node name in the %%! line for deployment.

main(Args) ->
	{ok, DepsDirs} = file:list_dir("deps"),
	Paths = ["deps/" ++ X ++ "/ebin" || X <- DepsDirs],
	code:add_paths(Paths),
	do_actions(Args).

do_actions([]) ->
	halt(0);

do_actions(["compile" | Tail]) ->
	compile_models(),
	do_actions(Tail);

do_actions(["build_db" | Tail]) ->
	build_db(),
	do_actions(Tail).

compile_models() ->
	{ok, ModelFiles} = file:list_dir("models"),
	compile_models(ModelFiles).

compile_models([]) -> ok;
compile_models([ModelFile | Tail]) ->
	File = filename:join(["models", ModelFile]),
	Res = boss_record_compiler:compile(File, [{out_dir, "ebin"}]),
	io:format("Compiling ~s:  ~p\n", [ModelFile, Res]),
	compile_models(Tail).

build_db() ->
	mnesia:create_schema([node()]),<commit_msg>Only compiling models if the src file is newer.<commit_after>#! /usr/bin/env escript
%%! -sname rpg_battlemap_dev
-mode(compile).

%% @doc Create the mnesia tables, or compile the boss_db models.  Update
%% the node name in the %%! line for deployment.

main(Args) ->
	{ok, DepsDirs} = file:list_dir("deps"),
	Paths = ["deps/" ++ X ++ "/ebin" || X <- DepsDirs],
	code:add_paths(Paths),
	do_actions(Args).

do_actions([]) ->
	halt(0);

do_actions(["compile" | Tail]) ->
	compile_models(),
	do_actions(Tail);

do_actions(["build_db" | Tail]) ->
	build_db(),
	do_actions(Tail).

compile_models() ->
	{ok, ModelFiles} = file:list_dir("models"),
	compile_models(ModelFiles).

compile_models([]) -> ok;
compile_models([ModelFile | Tail]) ->
	File = filename:join(["models", ModelFile]),
	ModelName = filename:rootname(ModelFile),
	ModelLastMod = filelib:last_modified(File),
	BeamLastMod = filelib:last_modified(filename:join(["ebin", ModelName ++ ".beam"])),
	Res = if
		ModelLastMod > BeamLastMod ->
			 boss_record_compiler:compile(File, [{out_dir, "ebin"}]);
		true ->	
			nochange
	end,
	io:format("Compiling ~s:  ~p\n", [ModelFile, Res]),
	compile_models(Tail).

build_db() ->
	mnesia:create_schema([node()]),
{'fraction_non_alphanumeric': 0.19178721418572095, 'fraction_numerical': 0.0009332711152589828, 'mean_word_length': 5.34319526627219, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 22, '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': '4576466', 'n_tokens_mistral': 826, 'n_tokens_neox': 811, 'n_words': 163}