Sha256: baaf767ab25b74422a0389eb54b39c3252c139f2b7cec27632c1d25594dc6f87

Contents?: true

Size: 580 Bytes

Versions: 2

Compression:

Stored size: 580 Bytes

Contents

# frozen_string_literal: true

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

desc 'Reindex the wiki pages.'
task reindex: :environment do
  indexer = ClWiki::IndexClient.new

  entries = Dir[File.join($wiki_path, "*#{$wikiPageExt}")]
  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, $wikiPageExt)
    indexer.reindex_page(page_name)
    print '.'
  end
  puts
  puts '100%'

  indexer.save
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
clwiki-2.4.0 lib/tasks/index.rake
clwiki-2.3.2 lib/tasks/index.rake