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
.config ⇒ Object
13
14
15
|
# File 'lib/nostos-source-illiad.rb', line 13
def self.config
@@config ||= Source::Illiad::Config.new
end
|
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
|
.poll ⇒ Object
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 = <<-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
|