Class: Toolhound::Job

Inherits:
Base
  • Object
show all
Defined in:
lib/toolhound-ruby/job.rb

Overview

Class to parse GitHub repository owner and name from URLs and to generate URLs

Constant Summary

Constants inherited from Base

Base::DATE_TIME_FORMAT, Base::DB_TYPE_REGEX

Instance Attribute Summary

Attributes inherited from Base

#client, #connection

Instance Method Summary collapse

Methods inherited from Base

#_build_joins, #_build_selects, #_build_where, #build_and_query, #build_group, #build_joins, #build_selects, #build_sql, #build_update_attributes, #build_update_sql, #build_where, #find, #formatted_table_and_column, #formatted_table_name, #formmatted_column_name, #get_operator, #initialize, #locale, #merge_options, #parse_time, primary_key, #primary_key, primary_key=, #procedure, #query, rename_attributes, renamed_attributes, #table_name, table_name, table_name=, #transform_attribute_key, #transform_attributes, #transform_procedure_key, #transform_procedure_value, #transform_procedure_variables, #update, #update_query

Methods included from Util

#acronym_regex, #acronyms, #camelize, #demodulize, #underscore

Constructor Details

This class inherits a constructor from Toolhound::Base

Instance Method Details

#all(options = {}) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/toolhound-ruby/job.rb', line 34

def all(options = {})
  entity_id = options[:entity_id]

  wheres  = default_wheres
  selects = default_selects
  joins   = default_joins

  joins << "
    INNER JOIN (
      SELECT DISTINCT intJobID FROM tblRentalCharge WHERE tblRentalCharge.intEntityID = '#{entity_id}' AND tblRentalCharge.intJobID is NOT NULL
    ) AS tblAssignees ON tblAssignees.intJobID = tblJob.intJobID" if entity_id


  build_and_query(
    joins: joins,
    selects: selects,
    where: wheres
  )

  # joins << "INNER JOIN tblRentalCharge ON tblRentalCharge.intEntityID = '#{entity_id}' AND tblRentalCharge.intJobID is NOT NULL" if entity_id
  # SELECT DISTINCT intJobID FROM tblRentalCharge WHERE tblRentalCharge.intEntityID = '100044' AND tblRentalCharge.intJobID is NOT NULL;

end

#default_joinsObject



19
20
21
22
23
24
25
# File 'lib/toolhound-ruby/job.rb', line 19

def default_joins
  arr = []
  arr << "INNER JOIN tblJobText ON (tblJobText.intJobID = tblJob.intJobID AND varLocaleID = '#{locale}')"
  # arr << "INNER JOIN tblRentalDetail ON (tblRentalDetail.intRentalDetailID = tblRentalItem.intRentalDetailID)"

  arr
end

#default_selectsObject

self.table_name = :rental self.primary_key = :int_rental_id



12
13
14
15
16
17
# File 'lib/toolhound-ruby/job.rb', line 12

def default_selects
  {
    job:      [:int_job_id, :bol_active, :dte_created_date, :dte_modified_date],
    job_text: [:int_job_text_id, :var_job_number, :var_job]
  }
end

#default_wheresObject



27
28
29
30
31
# File 'lib/toolhound-ruby/job.rb', line 27

def default_wheres
  [
    {"job.bol_active" => true}
  ]
end

#insert(variables = {}) ⇒ Object



58
59
60
61
# File 'lib/toolhound-ruby/job.rb', line 58

def insert(variables = {})
  vars = {created_user_id: 1, modified_user_id: 1, active: true, job: nil, created_date: nil, modified_date: nil}
  # procedure("Job_Insert", vars)
end

#remove(job_id) ⇒ Object



63
64
65
# File 'lib/toolhound-ruby/job.rb', line 63

def remove(job_id)
  # procedure("Job_Delete", {job_id: job_id})
end