some fixes
This commit is contained in:
parent
311f8acbe9
commit
2691864954
|
@ -498,18 +498,11 @@ class UniversalTablesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def tag_cloud
|
def tag_cloud
|
||||||
tables = UTable.filter_by_widget_categories(OrbitHelper.widget_categories,false)
|
ma = ModuleApp.find_by_key("universal_table")
|
||||||
tags = TableTag.where(:u_table_id.in => tables.pluck(:id))
|
|
||||||
hashtags = tags.map do |tag|
|
|
||||||
{
|
{
|
||||||
"title" => "##{tag.title}",
|
"extras" => {
|
||||||
"count" => tag.table_entries.count,
|
"orbithashtags" => ma.hashtags.get_all_module_hashtags_for_frontend_with_weight(OrbitHelper.widget_more_url)
|
||||||
"url_to_show" => "#{OrbitHelper.widget_more_url}?tag=#{tag.title}"
|
|
||||||
}
|
}
|
||||||
end
|
|
||||||
{
|
|
||||||
"hashtags" => hashtags,
|
|
||||||
"extras" => {}
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -176,14 +176,16 @@ namespace :universal_table_tasks do
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Migrate old tags to new tags"
|
desc "Migrate old tags to new tags"
|
||||||
task :migrate_tags => :environment do
|
task :migrate_hashtags => :environment do
|
||||||
module_app = ModuleApp.find_by_key("universal_table")
|
module_app = ModuleApp.find_by_key("universal_table")
|
||||||
dataset = {}
|
dataset = {}
|
||||||
TableTag.all.each do |tt|
|
TableTag.all.each do |tt|
|
||||||
next if tt.title.blank? # Skip if tag name is blank
|
next if tt.title.blank? # Skip if tag name is blank
|
||||||
|
next if tt.table_entries.empty? # Skip if no entries are associated with the tag
|
||||||
puts "Processing tag: #{tt.title}"
|
puts "Processing tag: #{tt.title}"
|
||||||
module_app.reload
|
module_app.reload
|
||||||
hashtag = module_app.hashtags.where(name: tt.title).first_or_initialize
|
tag_str = tt.title.gsub(/^#+/, '').downcase.strip
|
||||||
|
hashtag = module_app.hashtags.where(name: tag_str).first_or_initialize
|
||||||
hashtag.module_app_ids << module_app.id.to_s unless hashtag.module_app_ids.include?(module_app.id.to_s)
|
hashtag.module_app_ids << module_app.id.to_s unless hashtag.module_app_ids.include?(module_app.id.to_s)
|
||||||
puts "New record #{hashtag.new_record?}"
|
puts "New record #{hashtag.new_record?}"
|
||||||
hashtag.save if hashtag.new_record?
|
hashtag.save if hashtag.new_record?
|
||||||
|
|
Loading…
Reference in New Issue