<commit_before>-module(mod_ginger_export).
-author("Driebit <<EMAIL>>").

-mod_title("Ginger export module").
-mod_description("Export a list of resources to a csv file").
-mod_prio(500).
-mod_depends([mod_export]).

-export([
    observe_admin_menu/3,
    do_data_export/1,
    do_data_export/2,
    get_content_type/1,
    set_filename/1,
    observe_export_resource_header/2,
    observe_export_resource_encode/2,
    observe_export_resource_data/2
]).

-include_lib("include/zotonic.hrl").
-include_lib("modules/mod_admin/include/admin_menu.hrl").

observe_admin_menu(admin_menu, Acc, Context) ->
    [
        #menu_item{
            id=ginger_export,
            parent=admin_modules,
            label=?__("Export to CSV", Context),
            url={admin_ginger_export}
        }|
        Acc
    ].

do_data_export(Context) ->
    Query = [
        {cat_exclude, "person"},
        {cat_exclude, "artifact"},<commit_msg>[export] Only show in menu to users with mod_export use privileges<commit_after>-module(mod_ginger_export).
-author("Driebit <<EMAIL>>").

-mod_title("Ginger export module").
-mod_description("Export a list of resources to a csv file").
-mod_prio(500).
-mod_depends([mod_export]).

-export([
    observe_admin_menu/3,
    do_data_export/1,
    do_data_export/2,
    get_content_type/1,
    set_filename/1,
    observe_export_resource_header/2,
    observe_export_resource_encode/2,
    observe_export_resource_data/2
]).

-include_lib("include/zotonic.hrl").
-include_lib("modules/mod_admin/include/admin_menu.hrl").

observe_admin_menu(admin_menu, Acc, Context) ->
    case z_acl:is_allowed(use, mod_export, Context) of
        true ->
            [
                #menu_item{
                    id=ginger_export,
                    parent=admin_modules,
                    label=?__("Export to CSV", Context),
                    url={admin_ginger_export}
                }|
                Acc
            ];
        false ->
            Acc
    end.

do_data_export(Context) ->
    Query = [
        {cat_exclude, "person"},
        {cat_exclude, "artifact"},
{'fraction_non_alphanumeric': 0.12404580152671756, 'fraction_numerical': 0.01049618320610687, 'mean_word_length': 2.6030927835051547, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, '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': '2882668', 'n_tokens_mistral': 712, 'n_tokens_neox': 694, 'n_words': 110}