<commit_before>package MediaWords::Controller::Api::V2::Tags;
use Modern::Perl "2013";
use MediaWords::CommonLibs;

use strict;
use warnings;
use MediaWords::DBI::StorySubsets;
use MediaWords::Controller::Api::V2::MC_REST_SimpleObject;

use Moose;
use namespace::autoclean;

BEGIN { extends 'MediaWords::Controller::Api::V2::MC_REST_SimpleObject' }

sub get_table_name
{
    return "tags";
}

sub list_query_filter_field
{
    return 'tag_sets_id';
}

1;
<commit_msg>add public param to tags<commit_after>package MediaWords::Controller::Api::V2::Tags;
use Modern::Perl "2013";
use MediaWords::CommonLibs;

use strict;
use warnings;
use MediaWords::DBI::StorySubsets;
use MediaWords::Controller::Api::V2::MC_REST_SimpleObject;

use Moose;
use namespace::autoclean;

BEGIN { extends 'MediaWords::Controller::Api::V2::MC_REST_SimpleObject' }

sub get_table_name
{
    return "tags";
}

sub list_query_filter_field
{
    return 'tag_sets_id';
}

sub _fetch_list
{
    my ( $self, $c, $last_id, $table_name, $id_field, $rows ) = @_;

    my $public = $c->req->params->{ public } || '';
    $public = $public eq '1' ? 1 : 0;

    if ( $public )
    {
        $c->dbis->query( <<END );
create temporary view tags as
    select t.tags_id, t.tag_sets_id, t.label, t.description, 
        t.show_on_media OR ts.show_on_media show_on_media,
        t.show_on_stories OR ts.show_on_stories show_on_stories
    from tags t
        join tag_sets ts on ( t.tag_sets_id = ts.tag_sets_id )
    where 
        t.show_on_media or ts.show_on_media or t.show_on_stories or ts.show_on_stories
END
    }

    return MediaWords::Controller::Api::V2::MC_REST_SimpleObject::_fetch_list( @_ );
}

1;

{'fraction_non_alphanumeric': 0.13090257023311416, 'fraction_numerical': 0.011954572624028692, 'mean_word_length': 4.655405405405405, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, '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': '1676387', 'n_tokens_mistral': 644, 'n_tokens_neox': 613, 'n_words': 127}