From 03ff87603ebca7064ff1c35f98990f26903f8417 Mon Sep 17 00:00:00 2001 From: bfs15 <bruno.serbena@gmail.com> Date: Thu, 18 May 2017 13:11:42 -0300 Subject: [PATCH] removed old unused tag task --- lib/tasks/tag_frequency_hash.rake | 42 ------------------------------- 1 file changed, 42 deletions(-) delete mode 100644 lib/tasks/tag_frequency_hash.rake diff --git a/lib/tasks/tag_frequency_hash.rake b/lib/tasks/tag_frequency_hash.rake deleted file mode 100644 index 791feabeb..000000000 --- a/lib/tasks/tag_frequency_hash.rake +++ /dev/null @@ -1,42 +0,0 @@ -require 'json' -namespace :tag do - desc 'Generate tag frequency hash' - task generate_tag_frequency_hash: :environment do - hash = {} - name = {} - - LearningObject.all.each do |lo| - # for each lo, count tags and tag pairs and add to hash - # if id1 <= id2 - # hash[id1][id2] will equal how many times tags with id1 and id2 appear together on a LO - # hash[id][id] will equal how many times tag of id appears - lo.tags.each.with_index do |t, i| - name[t.id] = t.name - hash[t.id] = {} if hash[t.id].nil? - if hash[t.id][t.id] != nil - hash[t.id][t.id] += 1 - else - hash[t.id][t.id] = 1 - end - lo.tags.drop(i+1).each do |t2| - hash[t2.id] = {} if hash[t2.id].nil? - - if hash[t.id][t2.id] != nil - hash[t.id][t2.id] += 1 - hash[t2.id][t.id] += 1 - else - hash[t.id][t2.id] = 1 - hash[t2.id][t.id] = 1 - end - end - end - end - - File.open("tag_frequency_hash.json", "w+") do |f| - f << hash.to_json - end - File.open("tag_name.json", "w+") do |f| - f << name.to_json - end - end -end -- GitLab