source: subversion/tile.openstreetmap.org/tile_details.rb @ 2176

Last change on this file since 2176 was 2119, checked in by steve, 13 years ago

add tile status script

  • Property svn:executable set to *
File size: 993 bytes
Line 
1require 'cgi'
2
3cgi = CGI.new
4
5module Foo
6  require 'mysql'
7  require 'date'
8  require 'time'
9  require 'singleton'
10
11  class Bar
12    def get_local_connection
13      begin
14        return Mysql.real_connect('localhost', 'tile', 'tile', 'tile')
15      rescue MysqlError => e
16        mysql_error(e)
17      end
18    end
19
20
21    def call_local_sql
22      dbh = nil
23      begin
24        dbh = get_local_connection
25        sql = yield
26        res = dbh.query(sql)
27return res #        if res.nil? then return true else return res end
28      rescue MysqlError =>ex
29        puts ex
30      ensure
31        dbh.close unless dbh.nil?
32      end
33      nil
34    end
35  end
36end
37x = cgi['x']
38y = cgi['y']
39z = cgi['z']
40
41if z and (z.to_i > 18 or z.to_i < 2)
42  exit
43end
44
45fb = Foo::Bar.new
46
47res = fb.call_local_sql { "select dirty, created_at from tiles where x = #{x} and y=#{y} and z=#{z} limit 1" }
48
49res.each_hash do |row|
50  puts "tile created at #{row['created_at']}"
51  puts "tile is awaiting re-render: #{row['dirty']}"
52end
53
Note: See TracBrowser for help on using the repository browser.