<commit_before># encoding: utf-8
namespace :tcc do

  desc 'TCC | Faz a migração dos dados do moodle para o Sistema de TCC'
  task :remote, [:coursemodule_id, :hub_position, :tcc_definition_id] => [:environment] do |t, args|

    moodle_config = YAML.load_file("#{Rails.root}/config/moodle.yml")['moodle']
    Remote::OnlineText.establish_connection moodle_config

    result = Remote::OnlineText.find_by_sql(["
 SELECT DISTINCT u.id as id, u.username as username, ot.onlinetext as text, otv.commenttext as comment, ot.assignment,
                 assub.status, otv.status as status_version, assub.timecreated, otv.timecreated as timecreated_version, g.grade
            FROM assign_submission AS assub
            JOIN assignsubmission_onlinetext AS ot
              ON (ot.submission = assub.id)
       LEFT JOIN assignsubmission_textversion AS otv
              ON (otv.submission = assub.id)
            JOIN user u
              ON (assub.userid = u.id)
            JOIN course_modules cm
              ON (cm.instance = assub.assignment)
            JOIN modules m
              ON (m.id = cm.module AND m.name LIKE 'assign')
       LEFT JOIN assign_grades g
              ON (u.id = g.userid AND g.assignment = assub.assignment)
            WHERE cm.id = ?
            ORDER BY u.username, ot.assignment, otv.timecreated", args[:coursemodule_id]])
    user_id = nil

    result.with_progress("Migrando #{result.count} tuplas do texto online #{args[:coursemodule_id]} do moodle para eixo #{args[:hub_position]}") do |val|
      # Consulta ordenada por usuário
      if user_id != val.id
        user_id = val.id
      end

      created_at = (val.timecreated_version.nil?) ? val.timecreated : val.timecreated_version
      status = (val.status_version.nil?) ? val.status : val.status_version

      tcc = get_tcc(user_id, args[:tcc_definition_id])

      tcc.tutor_group = TutorGroup::get_tutor_group(val.username)<commit_msg>Refatorações e acrescentando nome de usuário<commit_after># encoding: utf-8
namespace :tcc do

  desc 'TCC | Faz a migração dos dados do moodle para o Sistema de TCC'
  task :remote, [:coursemodule_id, :hub_position, :tcc_definition_id] => [:environment] do |t, args|

    moodle_config = YAML.load_file("#{Rails.root}/config/moodle.yml")['moodle']
    Remote::OnlineText.establish_connection moodle_config

    result = Remote::OnlineText.find_by_sql(["
 SELECT DISTINCT u.id as id, u.username as username, ot.onlinetext as text, otv.commenttext as comment, ot.assignment,
                 assub.status, otv.status as status_version, assub.timecreated, otv.timecreated as timecreated_version, g.grade
            FROM assign_submission AS assub
            JOIN assignsubmission_onlinetext AS ot
              ON (ot.submission = assub.id)
       LEFT JOIN assignsubmission_textversion AS otv
              ON (otv.submission = assub.id)
            JOIN user u
              ON (assub.userid = u.id)
            JOIN course_modules cm
              ON (cm.instance = assub.assignment)
            JOIN modules m
              ON (m.id = cm.module AND m.name LIKE 'assign')
       LEFT JOIN assign_grades g
              ON (u.id = g.userid AND g.assignment = assub.assignment)
            WHERE cm.id = ?
            ORDER BY u.username, ot.assignment, otv.timecreated", args[:coursemodule_id]])

    result.with_progress("Migrando #{result.count} tuplas do texto online #{args[:coursemodule_id]} do moodle para eixo #{args[:hub_position]}") do |val|
      user_id = val.id

      created_at = (val.timecreated_version.nil?) ? val.timecreated : val.timecreated_version

      tcc = get_tcc(user_id, args[:tcc_definition_id])

      tcc.tutor_group = TutorGroup::get_tutor_group(val.username)
      tcc.name = MoodleUser::get_name(user_id)
{'fraction_non_alphanumeric': 0.09729586426299046, 'fraction_numerical': 0.0005302226935312832, 'mean_word_length': 2.8226950354609928, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '4074913', 'n_tokens_mistral': 1245, 'n_tokens_neox': 1202, 'n_words': 306}