0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-09 21:45:25 +08:00
discourse/script/import_scripts/socialcast/title.rb
Jarek Radosz 09d07fc418
DEV: Enable Style/RedundantParentheses rubocop rule (#40095)
(to be enabled in the shared config)
2026-05-19 15:48:09 +02:00

28 lines
813 B
Ruby
Vendored

# frozen_string_literal: true
require_relative "socialcast_message"
require_relative "socialcast_user"
require_relative "../base"
MESSAGES_DIR = "output/messages"
def titles
topics = 0
total = count_files(MESSAGES_DIR)
Dir.foreach(MESSAGES_DIR) do |filename|
next if filename == "." || filename == ".."
message_json = File.read MESSAGES_DIR + "/" + filename
message = SocialcastMessage.new(message_json)
next unless message.title
#puts "#{filename}, #{message.replies.size}, #{message.topic[:raw].size}, #{message.message_type}, #{message.title}"
puts "[#{message.title}](#{message.url})"
topics += 1
end
puts "", "Imported #{topics} topics. Skipped #{total - topics}."
end
def count_files(path)
Dir.foreach(path).select { |f| f != "." && f != ".." }.count
end
titles