discourse/script/import_scripts/socialcast/title.rb

28 lines
848 B
Ruby
Raw Normal View History

2016-05-26 02:54:38 -04:00
require_relative './socialcast_message.rb'
require_relative './socialcast_user.rb'
require 'set'
require File.expand_path(File.dirname(__FILE__) + "/../base.rb")
MESSAGES_DIR = "output/messages"
def titles
topics = 0
total = count_files(MESSAGES_DIR)
Dir.foreach(MESSAGES_DIR) do |filename|
2017-07-27 21:20:09 -04:00
next if filename == ('.') || filename == ('..')
2016-05-26 02:54:38 -04:00
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)
2017-07-27 21:20:09 -04:00
Dir.foreach(path).select { |f| f != '.' && f != '..' }.count
2016-05-26 02:54:38 -04:00
end
titles