From 269186495409c6e856f91b42648add7e8a598b20 Mon Sep 17 00:00:00 2001 From: rulingcom Date: Fri, 8 Aug 2025 22:45:48 +0800 Subject: [PATCH] some fixes --- app/controllers/universal_tables_controller.rb | 15 ++++----------- lib/tasks/universal_table_tasks.rake | 6 ++++-- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/app/controllers/universal_tables_controller.rb b/app/controllers/universal_tables_controller.rb index ba59fef..c1d64ae 100755 --- a/app/controllers/universal_tables_controller.rb +++ b/app/controllers/universal_tables_controller.rb @@ -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 diff --git a/lib/tasks/universal_table_tasks.rake b/lib/tasks/universal_table_tasks.rake index 0b6bb1f..8503190 100755 --- a/lib/tasks/universal_table_tasks.rake +++ b/lib/tasks/universal_table_tasks.rake @@ -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?