some fixes

This commit is contained in:
rulingcom 2025-08-08 22:45:48 +08:00
parent 311f8acbe9
commit 2691864954
2 changed files with 8 additions and 13 deletions

View File

@ -498,18 +498,11 @@ class UniversalTablesController < ApplicationController
end
def tag_cloud
tables = UTable.filter_by_widget_categories(OrbitHelper.widget_categories,false)
tags = TableTag.where(:u_table_id.in => tables.pluck(:id))
hashtags = tags.map do |tag|
{
"title" => "##{tag.title}",
"count" => tag.table_entries.count,
"url_to_show" => "#{OrbitHelper.widget_more_url}?tag=#{tag.title}"
}
end
ma = ModuleApp.find_by_key("universal_table")
{
"hashtags" => hashtags,
"extras" => {}
"extras" => {
"orbithashtags" => ma.hashtags.get_all_module_hashtags_for_frontend_with_weight(OrbitHelper.widget_more_url)
}
}
end
end

View File

@ -176,14 +176,16 @@ namespace :universal_table_tasks do
end
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")
dataset = {}
TableTag.all.each do |tt|
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}"
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)
puts "New record #{hashtag.new_record?}"
hashtag.save if hashtag.new_record?