Permalink
Browse files

Fix merge breakage.

  • Loading branch information...
1 parent 3a778b8 commit 0cb95862634667c871af90f0456aa217c8040b0f @greensnark greensnark committed Aug 15, 2012
Showing with 60 additions and 192 deletions.
  1. +25 −171 commands/crawl-data.yml
  2. +0 −1 commands/helper.rb
  3. +1 −1 commands/sql_connection.rb
  4. +33 −18 commands/sqlhelper.rb
  5. +1 −1 spec/spec_helper.rb
@@ -29,118 +29,6 @@ sql-field-names:
map: mapname
##
-# Fake query fields that are transformed into a real query field by code in
-# query_synthetic.rb
-fake-fields-with-type:
- - when*
- - game*
-
-##
-# Field type suffixes:
-# - I (integer)
-# - D (date+time)
-#
-# - * (not summarisable)
-logrecord-fields-with-type:
- - idI*
- - file*
- - alpha
- - src
- - v
- - cv
- - lv
- - scI*
- - name
- - uidI
- - race
- - crace
- - cls
- - char
- - xlI
- - sk
- - sklevI
- - title
- - ktyp
- - killer
- - ckiller
- - ikiller
- - kpath
- - kmod
- - kaux
- - ckaux
- - place
- - br
- - lvlI
- - ltyp
- - hpI
- - mhpI
- - mmhpI
- - damI
- - strI
- - intI
- - dexI
- - god
- - pietyI
- - penI
- - wizI
- - startD*
- - endD*
- - durI*
- - turnI*
- - uruneI
- - nruneI
- - tmsg
- - vmsg
- - splat
- - rstart*
- - rend*
- - ntvI
- - map
- - mapdesc
-
-milestone-fields-with-type:
- - game_idI
- - idI*
- - file*
- - alpha
- - src
- - v
- - cv
- - name
- - race
- - crace
- - cls
- - char
- - xlI
- - sk
- - sklevI
- - title
- - place
- - br
- - lvlI
- - ltyp
- - hpI
- - mhpI
- - mmhpI
- - strI
- - intI
- - dexI
- - god
- - durI*
- - turnI*
- - uruneI
- - nruneI
- - timeD*
- - rtime*
- - rstart*
- - verb
- - noun
- - milestone
- - ntvI
- - oplace
-
-
-##
# game types recognized by !lg and friends, mapped to the table name prefix.
# For instance, Crawl games will query `logrecord` and `milestone`, Sprint
# games will query `spr_logrecord` and `spr_milestone` and so on.
@@ -404,7 +292,6 @@ branches:
- Blade
- Temple
- Abyss
- - Sprint
- WizLab
- Sewer
- Bailey
@@ -595,16 +482,22 @@ aggregate-function-types:
std: I
variance: I
-logfields-with-type:
- - idI
+##
+# Field type suffixes:
+# - I (integer)
+# - D (date+time)
+#
+# - * (not summarisable)
+logrecord-fields-with-type:
+ - idI*
- game_key
- file
- alpha
- src
- v
- cv
- lv
- - scI
+ - scI*
- name
- uidI
- race
@@ -638,10 +531,10 @@ logfields-with-type:
- pietyI
- penI
- wizI
- - startD
- - endD
- - durI
- - turnI
+ - startD*
+ - endD*
+ - durI*
+ - turnI*
- uruneI
- nruneI
- tmsg
@@ -654,7 +547,7 @@ logfields-with-type:
- mapdesc
- tiles
-milefields-with-type:
+milestone-fields-with-type:
- game_key
- idI
- file
@@ -682,65 +575,26 @@ milefields-with-type:
- intI
- dexI
- god
- - durI
- - turnI
+ - durI*
+ - turnI*
- uruneI
- nruneI
- - timeD
- - rtime
- - rstart
+ - timeD*
+ - rtime*
+ - rstart*
- verb
- noun
- milestone
- ntvI
- oplace
- tiles
-fakefields-with-type:
- - when
-
-logfields-summarisable:
- - v
- - name
- - race
- - cls
- - char
- - xl
- - sk
- - sklev
- - title
- - ktyp
- - place
- - br
- - lvl
- - ltyp
- - killer
- - ikiller
- - god
- - urune
- - nrune
- - src
- - str
- - int
- - dex
- - kaux
- - ckiller
- - cv
- - ckaux
- - crace
- - kmod
- - splat
- - dam
- - hp
- - mhp
- - mmhp
- - piety
- - pen
- - alpha
- - ntv
- - map
- - mapdesc
- - tiles
+##
+# Fake query fields that are transformed into a real query field by code in
+# query_synthetic.rb
+fake-fields-with-type:
+ - when*
+ - game*
milestone-types:
- abyss.enter
View
@@ -2,7 +2,6 @@
require 'set'
require 'date'
-require 'command_context'
require 'yaml'
SERVERS_FILE = 'servers.yml'
@@ -40,7 +40,7 @@ def self.sql_connection
end
def self.connect
- DBHandle.new(DBI.connect('DBI:Mysql:' + DBNAME, DBUSER, DBPASS))
+ DBHandle.new(DBI.connect('DBI:Pg:' + DBNAME, DBUSER, DBPASS))
end
end
View
@@ -21,17 +21,14 @@
include Tourney
include HenzellConfig
-DBNAME = ENV['HENZELL_DBNAME'] || 'henzell'
-DBUSER = ENV['HENZELL_DBUSER'] || 'henzell'
-DBPASS = ENV['HENZELL_DBPASS'] || 'henzell'
-
CFG = YAML.load_file(LG_CONFIG_FILE)
LG_SERVER_CFG = YAML.load_file(LG_SERVERS_FILE)
# Don't use more than this much memory (bytes)
MAX_MEMORY_USED = 768 * 1024 * 1024
Process.setrlimit(Process::RLIMIT_AS, MAX_MEMORY_USED)
+GAME_TYPE_DEFAULT = CFG['default-game-type']
GAME_SPRINT = 'sprint'
GAMES = CFG['game-type-prefixes'].keys
GAME_PREFIXES = CFG['game-type-prefixes']
@@ -97,9 +94,6 @@
MILEFIELDS_DECORATED = CFG['milestone-fields-with-type']
FAKEFIELDS_DECORATED = CFG['fake-fields-with-type']
-LOGFIELDS_SUMMARISABLE =
- Hash[ *(CFG['logfields-summarisable'].map { |x| [x, true] }.flatten) ]
-
# Never fetch more than 5000 rows, kthx.
ROWFETCH_MAX = 5000
DBFILE = "#{ENV['HOME']}/logfile.db"
@@ -127,20 +121,24 @@
fdec.each do |lf|
class << lf
def name
- self.sub(/[ID]$/, '')
+ self.sub(/[ID*]+$/, '')
end
def fix_date(v)
sql2logdate(v)
end
+ def summarisable?
+ self !~ /\*/
+ end
+
def value(v)
- (self =~ /I$/) ? v.to_i :
- (self =~ /D$/) ? fix_date(v) : v
+ (self =~ /I/) ? v.to_i :
+ (self =~ /D/) ? fix_date(v) : v
end
end
- if lf =~ /([ID])$/
+ if lf =~ /([ID])\*?$/
type = $1
else
type = 'S'
@@ -149,17 +147,20 @@ def value(v)
end
end
+LOG2SQL = CFG['sql-field-names']
(LOGFIELDS_DECORATED + MILEFIELDS_DECORATED).each do |x|
LOG2SQL[x.name] = x.name unless LOG2SQL[x.name]
end
-MILEFIELDS_SUMMARISABLE = \
- Hash[ *MILEFIELDS_DECORATED.map { |x| [ x.name, true ] }.flatten ]
+LOGFIELDS_SUMMARISABLE =
+ Hash[ *(LOGFIELDS_DECORATED.find_all { |x| x.summarisable? }.map { |x|
+ [x.name, true]
+ }.flatten) ]
-# But suppress attempts to summarise by bad fields.
-%w/id dur turn rtime rstart tend ttime tstart/.each do |x|
- MILEFIELDS_SUMMARISABLE[x] = nil
-end
+MILEFIELDS_SUMMARISABLE =
+ Hash[ *(MILEFIELDS_DECORATED.find_all { |x| x.summarisable? }.map { |x|
+ [x.name, true]
+ }.flatten) ]
module GameContext
@@game = GAME_TYPE_DEFAULT
@@ -232,7 +233,7 @@ def field_type(field)
end
def dbfield(field)
- raise "Bad field #{field}" unless field?(field)
+ raise "Bad field '#{field}'" unless field?(field)
prefix, suffix = split_field(field)
if @table =~ /^logrecord/ || ((!prefix || prefix == @table_alias) \
@@ -307,6 +308,20 @@ def initialize(table, entity_name, alt=nil)
$DB_HANDLE = nil
+def sql2logdate(v)
+ if v.is_a?(DateTime)
+ v = v.strftime('%Y-%m-%d %H:%M:%S')
+ else
+ v = v.to_s
+ end
+ if v =~ /^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/
+ # Note we're munging back to POSIX month (0-11) here.
+ $1 + sprintf("%02d", $2.to_i - 1) + $3 + $4 + $5 + $6 + 'S'
+ else
+ v
+ end
+end
+
def with_query_context(ctx)
old_context = $CTX
begin
View
@@ -2,6 +2,6 @@
require 'commands/sql_builder'
require 'henzell_helpers'
-Spec::Runner.configure do |config|
+RSpec.configure do |config|
include HenzellHelpers
end

0 comments on commit 0cb9586

Please sign in to comment.