Class: Hyphy::SQLStatement

Inherits:
Sequel::Model
  • Object
show all
Defined in:
lib/hyphy/models/sql_statement.rb

Constant Summary collapse

DIGIT_MARKER =
'<digit>'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.truncate_tableObject



45
46
47
# File 'lib/hyphy/models/sql_statement.rb', line 45

def self.truncate_table
  Hyphy::DB[:sql_statements].truncate
end

Instance Method Details

#add_metadata(key, value) ⇒ Object



38
39
40
41
42
43
# File 'lib/hyphy/models/sql_statement.rb', line 38

def (key, value)
   = 
  [key] = value
  self. = JSON()
  save
end

#digitlessObject



25
26
27
# File 'lib/hyphy/models/sql_statement.rb', line 25

def digitless
  without_digits = stripped_statement.gsub(/\d+/, DIGIT_MARKER)
end

#durationObject



17
18
19
# File 'lib/hyphy/models/sql_statement.rb', line 17

def duration
  @duration ||= (end_time - start_time)
end

#metadataObject



33
34
35
36
# File 'lib/hyphy/models/sql_statement.rb', line 33

def 
  return {} unless 
  JSON.parse()
end

#stripped_statementObject



21
22
23
# File 'lib/hyphy/models/sql_statement.rb', line 21

def stripped_statement
  statement.strip
end

#traceObject



29
30
31
# File 'lib/hyphy/models/sql_statement.rb', line 29

def trace
  JSON.parse(trace_json)
end