Revision 979:56a38a9f6204

View differences:

extra/soundsoftware/get-apache-log-stats.rb
38 38
parseable = 0
39 39
unparseable = 0
40 40

  
41
def known_project?(project)
41
def is_public_project?(project)
42 42
  if !project
43 43
    false
44 44
  elsif @projects.key?(project)
45
    true
45
    @projects[project].is_public? 
46 46
  else
47 47
    pobj = Project.find_by_identifier(project)
48 48
    if pobj
49 49
      @projects[project] = pobj
50
      true
50
      pobj.is_public?
51 51
    else
52
      print "Project not found: ", project
52
      print "Project not found: ", project, "\n"
53 53
      false
54 54
    end
55 55
  end
56 56
end
57 57

  
58
ARGF.each do |line|
58
STDIN.each do |line|
59 59

  
60 60
  record = parser.parse(line)
61 61

  
......
69 69

  
70 70
  # discard, but count, unparseable lines
71 71
  if not record
72
    print "Line not parseable: ", line, "\n"
72 73
    unparseable += 1
73 74
    next
74 75
  end
......
84 85

  
85 86
  # split into method, path, protocol
86 87
  if not request =~ /^[^\s]+ ([^\s]+) [^\s]+$/
88
    print "Line not parseable (bad method, path, protocol): ", line, "\n"
87 89
    unparseable += 1
88 90
    next
89 91
  end
......
95 97
  # should have at least two elements unless path is "/"; first should
96 98
  # be empty (begins with /)
97 99
  if path != "/" and (components.size < 2 or components[0] != "")
100
    print "Line not parseable (degenerate path): ", line, "\n"
98 101
    unparseable += 1
99 102
    next
100 103
  end
......
104 107
    # path is /hg/project?something or /hg/project/something
105 108

  
106 109
    project = components[2].split("?")[0]
107
    if not known_project?(project)
110
    if not is_public_project?(project)
108 111
      next
109 112
    end
110 113

  
......
123 126
    # path is /projects/project or /projects/project/something
124 127

  
125 128
    project = components[2]
126
    if not known_project?(project)
129
    project = project.split("?")[0] if project
130
    if not is_public_project?(project)
127 131
      next
128 132
    end
129 133

  

Also available in: Unified diff