Sha256: 6d6e02e2c8196ea78df51fff5a361676a881a5102a345da767346fc76a36cb68

Contents?: true

Size: 597 Bytes

Versions: 21

Compression:

Stored size: 597 Bytes

Contents

# frozen_string_literal: true

def pct_done(done, total)
  pct = (done.fdiv(total) * 100).to_i
  pct.to_s.rjust(3) + '%'
end

desc 'Reindex the wiki pages.'
task reindex: :environment do
  indexer = ClWiki::MemoryIndexer.instance

  entries = Dir[File.join($wiki_conf.wiki_path, "*#{ClWiki::FILE_EXT}")]
  entries.each_with_index.map do |fn, idx|
    if idx.divmod(100)[1].zero?
      puts
      print "#{pct_done(idx, entries.length)}: "
    end

    page_name = File.basename(fn, ClWiki::FILE_EXT)
    indexer.reindex_page(page_name)
    print '.'
  end
  puts
  puts '100%'

  indexer.save
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
clwiki-3.3.2 lib/tasks/index.rake
clwiki-3.3.0 lib/tasks/index.rake
clwiki-3.2.6 lib/tasks/index.rake
clwiki-3.2.5 lib/tasks/index.rake
clwiki-3.2.4 lib/tasks/index.rake
clwiki-3.2.3 lib/tasks/index.rake
clwiki-3.2.2 lib/tasks/index.rake
clwiki-3.2.1 lib/tasks/index.rake
clwiki-3.2.0 lib/tasks/index.rake
clwiki-3.1.6 lib/tasks/index.rake
clwiki-3.1.5 lib/tasks/index.rake
clwiki-3.1.4 lib/tasks/index.rake
clwiki-3.1.3 lib/tasks/index.rake
clwiki-3.1.2 lib/tasks/index.rake
clwiki-3.1.1 lib/tasks/index.rake
clwiki-3.1.0 lib/tasks/index.rake
clwiki-3.0.4 lib/tasks/index.rake
clwiki-3.0.3 lib/tasks/index.rake
clwiki-3.0.2 lib/tasks/index.rake
clwiki-3.0.1 lib/tasks/index.rake