mirror of
https://github.com/discourse/discourse.git
synced 2024-12-19 19:04:19 +08:00
694b5f108b
These (21 + 3 from previous PRs) are soon to be enabled in rubocop-discourse: Capybara/VisibilityMatcher Lint/DeprecatedOpenSSLConstant Lint/DisjunctiveAssignmentInConstructor Lint/EmptyConditionalBody Lint/EmptyEnsure Lint/LiteralInInterpolation Lint/NonLocalExitFromIterator Lint/ParenthesesAsGroupedExpression Lint/RedundantCopDisableDirective Lint/RedundantRequireStatement Lint/RedundantSafeNavigation Lint/RedundantStringCoercion Lint/RedundantWithIndex Lint/RedundantWithObject Lint/SafeNavigationChain Lint/SafeNavigationConsistency Lint/SelfAssignment Lint/UnreachableCode Lint/UselessMethodDefinition Lint/Void Previous PRs: Lint/ShadowedArgument Lint/DuplicateMethods Lint/BooleanSymbol RSpec/SpecFilePathSuffix
29 lines
865 B
Ruby
29 lines
865 B
Ruby
# frozen_string_literal: true
|
|
|
|
require_relative "./socialcast_message.rb"
|
|
require_relative "./socialcast_user.rb"
|
|
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|
|
|
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
|