lib/lc_discovery/extractors/project_extractor.rb
def proj_file_stats

    map_num, sei_num, file_count, byte_size = 0, 0, 0, 0 
    sei_ago, map_ago, file_ago = [], [], []

    oldest_file_mod = Time.now
    newest_file_mod = Time.at(0)

    Dir.glob(File.join(@project, "**/*"), File::FNM_DOTMATCH).each do |f| 
      next unless File.exists?(f)
      stat = File.stat(f)

      days_ago = days_since(stat.mtime)

      byte_size += stat.size
      file_count += 1 if File.file?(f)
      oldest_file_mod = stat.mtime if stat.mtime < oldest_file_mod
      newest_file_mod = stat.mtime if stat.mtime > newest_file_mod

      file_ago << days_ago unless f.match /gxdb.*\.(db|log)$/i

      if f.match /\interp\.svx$/i
        sei_num += 1
        sei_ago << days_ago
      end

      if f.match /\.(gmp|shp)$/i
        map_num += 1
        map_ago << days_ago
      end

    end

    age_layers_maps = (map_ago.inject(:+).to_f / map_ago.size).round rescue nil
    age_sv_interps = (sei_ago.inject(:+).to_f / sei_ago.size).round rescue nil
    age_file_mod = (file_ago.inject(:+).to_f / file_ago.size).round rescue nil

    {
      num_layers_maps: map_num,
      num_sv_interps: sei_num,
      #oldest_file_mod: oldest_file_mod.utc.iso8601,
      #newest_file_mod: newest_file_mod.utc.iso8601,
      oldest_file_mod: oldest_file_mod.to_i,
      newest_file_mod: newest_file_mod.to_i,
      byte_size: byte_size,
      human_size: Filesize.from("#{byte_size} B").pretty.gsub("i",""),
      file_count: file_count,
      age_layers_maps: age_layers_maps,
      age_sv_interps: age_sv_interps,
      age_file_mod: age_file_mod
    }

  end
# ugly, but glob seems to offer best peformance. Maybe do native powershell?
ugly, but glob seems to offer best peformance.
ugly but glob seems to offer best peformance .
def proj_file_stats
    map_num, sei_num, file_count, byte_size = 0, 0, 0, 0 
    sei_ago, map_ago, file_ago = [], [], []
    oldest_file_mod = Time.now
    newest_file_mod = Time.at(0)
    Dir.glob(File.join(@project, "**/*"), File::FNM_DOTMATCH).each do |f| 
      next unless File.exists?(f)
      stat = File.stat(f)
      days_ago = days_since(stat.mtime)
      byte_size += stat.size
      file_count += 1 if File.file?(f)
      oldest_file_mod = stat.mtime if stat.mtime < oldest_file_mod
      newest_file_mod = stat.mtime if stat.mtime > newest_file_mod
      file_ago << days_ago unless f.match /gxdb.*\.(db|log)$/i
      if f.match /\interp\.svx$/i
        sei_num += 1
        sei_ago << days_ago
      end
      if f.match /\.(gmp|shp)$/i
        map_num += 1
        map_ago << days_ago
      end
    end
    age_layers_maps = (map_ago.inject(:+).to_f / map_ago.size).round rescue nil
    age_sv_interps = (sei_ago.inject(:+).to_f / sei_ago.size).round rescue nil
    age_file_mod = (file_ago.inject(:+).to_f / file_ago.size).round rescue nil
    {
      num_layers_maps: map_num,
      num_sv_interps: sei_num,
      oldest_file_mod: oldest_file_mod.to_i,
      newest_file_mod: newest_file_mod.to_i,
      byte_size: byte_size,
      human_size: Filesize.from("#{byte_size} B").pretty.gsub("i",""),
      file_count: file_count,
      age_layers_maps: age_layers_maps,
      age_sv_interps: age_sv_interps,
      age_file_mod: age_file_mod
    }
  end
def proj_file_stats map_num , sei_num , file_count , byte_size = 0 , 0 , 0 , 0 sei_ago , map_ago , file_ago = [ ] , [ ] , [ ] oldest_file_mod = Time . now newest_file_mod = Time . at ( 0 ) Dir . glob ( File . join ( @project , "**/*" ) , File :: FNM_DOTMATCH ) . each do | f | next unless File . exists? ( f ) stat = File . stat ( f ) days_ago = days_since ( stat . mtime ) byte_size += stat . size file_count += 1 if File . file? ( f ) oldest_file_mod = stat . mtime if stat . mtime < oldest_file_mod newest_file_mod = stat . mtime if stat . mtime > newest_file_mod file_ago << days_ago unless f . match / gxdb.* \. (db|log)$ /i if f . match / \i nterp \. svx$ /i sei_num += 1 sei_ago << days_ago end if f . match / \. (gmp|shp)$ /i map_num += 1 map_ago << days_ago end end age_layers_maps = ( map_ago . inject ( :+ ) . to_f / map_ago . size ) . round rescue nil age_sv_interps = ( sei_ago . inject ( :+ ) . to_f / sei_ago . size ) . round rescue nil age_file_mod = ( file_ago . inject ( :+ ) . to_f / file_ago . size ) . round rescue nil { num_layers_maps : map_num , num_sv_interps : sei_num , oldest_file_mod : oldest_file_mod . to_i , newest_file_mod : newest_file_mod . to_i , byte_size : byte_size , human_size : Filesize . from ( "#{byte_size} B" ) . pretty . gsub ( "i" , "" ) , file_count : file_count , age_layers_maps : age_layers_maps , age_sv_interps : age_sv_interps , age_file_mod : age_file_mod } end
ugly, but glob seems to offer best peformance.
ugly but glob seems to offer best peformance .
#oldest_file_mod: oldest_file_mod.utc.iso8601, #newest_file_mod: newest_file_mod.utc.iso8601,