Module: Source::Illiad

Defined in:
lib/nostos-source-illiad.rb,
lib/nostos-source-illiad/config.rb,
lib/nostos-source-illiad/record.rb,
lib/nostos-source-illiad/railtie.rb,
lib/nostos-source-illiad/version.rb

Defined Under Namespace

Classes: Config, Railtie, Record

Constant Summary collapse

VERSION =
"0.0.4"

Class Method Summary collapse

Class Method Details

.configObject



13
14
15
# File 'lib/nostos-source-illiad.rb', line 13

def self.config
  @@config ||= Source::Illiad::Config.new
end

.configure {|self.config| ... } ⇒ Object

Yields:



17
18
19
# File 'lib/nostos-source-illiad.rb', line 17

def self.configure
  yield self.config
end

.find(id) ⇒ Object



21
22
23
# File 'lib/nostos-source-illiad.rb', line 21

def self.find(id)
  ::Illiad::AR::Transaction.find(id).to_record
end

.pollObject

Poll Illiad for new transactions to process. The strategy is to find all transactions that have had the status Customer Notified Via E-Mail within the past ‘number_of_days_old_transactions` days. We must join the Tracking table because a transaction theoretically could go from `Customer Notified Via E-Mail` to another status quicker than our processing runs.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/nostos-source-illiad.rb', line 31

def self.poll
  # SQL to identify records as old as 60 days
  sql = <<-SQL
    SELECT
      Tracking.TransactionNumber
    , Username
    , LoanTitle
    , LoanAuthor
    , DueDate
    , TransactionStatus
    FROM
      Tracking
      INNER JOIN Transactions ON Tracking.TransactionNumber = Transactions.TransactionNumber
    WHERE
      Tracking.ChangedTo = 'Customer Notified Via E-Mail' AND
      Tracking.DateTime > CURRENT_TIMESTAMP - #{config.number_of_days_to_poll} AND
      Transactions.RequestType = 'Loan'
  SQL

  ::Illiad::AR::Transaction.find_by_sql(sql).map {|t| t.to_record}
end