<commit_before>package CCNQ::Portal::Inner::RatingTable;
# Copyright (C) 2010  <NAME>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
use strict; use warnings;
use utf8;

use Dancer ':syntax';
use CCNQ::Portal;
use CCNQ::Portal::I18N;
use CCNQ::Portal::Util;

use CCNQ::AE;
use CCNQ::API;

# ******* Utilities ***********

sub gather_fields {
  return [qw(
    country us_state
    count_cost
    duration_rate
    initial_duration increment_duration
    jurisdiction rate
  )];
}

sub gather_ratingtables {
  my $cv = AE::cv;
  CCNQ::API::rating_table($cv);
  my $tables = CCNQ::AE::receive($cv);
  return $tables;
}

sub gather_prefixes {
  my $cv = AE::cv;
  my $table_name = session('rating_table');
  return [] if not defined $table_name;
  CCNQ::API::rating_table($table_name,$cv);
  my $ids = CCNQ::AE::receive_ids($cv);
  return $ids;
}

sub gather_prefix {
  my ($prefix) = @_;

  my $table_name = session('rating_table');
  return if not defined $table_name or not defined $prefix;

  debug("gather_prefix($table_name,$prefix)");
  # Get the information from the API.
  my $cv2 = AE::cv;
  CCNQ::API::rating_table($table_name,$prefix,$cv2);
  my $prefix_data = CCNQ::AE::receive_first_doc($cv2);
  return $prefix_data;
}

# ******* Rating-table selection ***********

sub set_rating_table {
  return CCNQ::Portal::content unless CCNQ::Portal->current_session->user and CCNQ::Portal->current_session->user->profile->is_admin;

  my $params = CCNQ::Portal::Util::neat({}, qw( rating_table ));

  if(defined $params->{rating_table}) {
    session rating_table => $params->{rating_table};
    var template_name => 'api/rating_table/edit';
    var rating_table_prefixes => \&gather_prefixes;
    var rating_table_fields => \&gather_fields;
    var rating_table_prefix => \&gather_prefix;
    return CCNQ::Portal::content;<commit_msg>do what i mean<commit_after>package CCNQ::Portal::Inner::RatingTable;
# Copyright (C) 2010  <NAME>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
use strict; use warnings;
use utf8;

use Dancer ':syntax';
use CCNQ::Portal;
use CCNQ::Portal::I18N;
use CCNQ::Portal::Util;

use CCNQ::AE;
use CCNQ::API;

# ******* Utilities ***********

sub gather_fields {
  return [qw(
    country us_state
    count_cost
    duration_rate
    initial_duration increment_duration
    jurisdiction rate
  )];
}

sub gather_ratingtables {
  my $cv = AE::cv;
  CCNQ::API::rating_table($cv);
  my $tables = CCNQ::AE::receive($cv);
  return $tables;
}

sub gather_prefixes {
  my $cv = AE::cv;
  my $table_name = session('rating_table');
  return [] if not defined $table_name;
  CCNQ::API::rating_table($table_name,$cv);
  my $ids = CCNQ::AE::receive_ids($cv);
  return $ids;
}

sub gather_prefix {
  my ($prefix) = @_;

  my $table_name = session('rating_table');
  return if not defined $table_name or not defined $prefix;

  # Get the information from the API.
  my $cv2 = AE::cv;
  CCNQ::API::rating_table($table_name,$prefix,$cv2);
  my $prefix_data = CCNQ::AE::receive($cv2);
  return $prefix_data;
}

# ******* Rating-table selection ***********

sub set_rating_table {
  return CCNQ::Portal::content unless CCNQ::Portal->current_session->user and CCNQ::Portal->current_session->user->profile->is_admin;

  my $params = CCNQ::Portal::Util::neat({}, qw( rating_table ));

  if(defined $params->{rating_table}) {
    session rating_table => $params->{rating_table};
    var template_name => 'api/rating_table/edit';
    var rating_table_prefixes => \&gather_prefixes;
    var rating_table_fields => \&gather_fields;
    var rating_table_prefix => \&gather_prefix;
    return CCNQ::Portal::content;
{'fraction_non_alphanumeric': 0.13552960800667221, 'fraction_numerical': 0.0045871559633027525, 'mean_word_length': 4.744910179640718, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4037808', 'n_tokens_mistral': 1604, 'n_tokens_neox': 1564, 'n_words': 467}