Skip to content

Instantly share code, notes, and snippets.

View jnwheeler44's full-sized avatar

Justin Wheeler jnwheeler44

View GitHub Profile
git commit -m 'First I did this
> Then I did that
> Finally, I finished it'
class Report
def date_reported_formatted(format='%m/%d/%Y ')
date_reported.strftime(format)
end
end
class NullReport
def method_missing(meth, *args)
"No Report"
end
class Result
def active_report
active_reports.first
end
def get_date_of_report
if active_report
active_report.date_reported.strftime('%m/%d/%Y ')
else
'No Report'
class Chair < ActiveRecord::Base
belongs_to :person
belongs_to :location
has_one :result
has_many :reports, :through=>:result
scope :with_active_viewed_report, joins(:report).where(:reports => {:active => 1, :viewed => 1})
scope :user_allowed, lambda { |user| where(:person_id => user.permission_owner_ids) }
# TODO: Remove location references; they aren't needed
class Chair < ActiveRecord::Base
belongs_to :person
belongs_to :location
has_one :result
has_many :reports, :through=>:result
def self.get_home_page_data(location, user)
# Looking at other spots in the code, I see that the individual fields
# aren't relevant, and the extra selected fields aren't referenced.
describe Chair do
it 'gets home page data' do
# These wouldn't really be here
location = Factory.create(:location)
chair = Factory.create(:chair)
user = Factory.create(:user)
Chair.get_home_page_data(location, user).should include(chair)
end
class Chair < ActiveRecord::Base
belongs_to :person
belongs_to :location
has_one :result
has_many :reports, :through=>:result
def self.get_home_page_data(location, user)
sql = 'SELECT DISTINCT c.id, c.received_on, c.info, c.number, c.condition_id,
p.first_name, p.last_name, p.middle_initial, '
sql += ' rp.active, rp.viewed, rp.printed, rs.diagnosis_id '
$ git confif --global help.autocorrect 1
git: 'confif' is not a git command. See 'git --help'.
Did you mean this?
config
[7] pry(main)> range = ((Date.today - 1000.years)..(Date.today + 1000.years))
=> Sun, 26 Oct 1012..Mon, 26 Oct 3012
[11] pry(main)> target = (Date.today + 999.years)
=> Sat, 26 Oct 3011
[12] pry(main)> Benchmark.measure { range.include? target }
=> 0.410000 0.000000 0.410000 ( 0.411619)
[13] pry(main)> Benchmark.measure { range === target }
,:$?ZZZ~$,,,=$:OZZ=Z,.,,=Z:ZZ,,,,$O~ZZ,OO,,.,,ZZZZ~,,,,,Z=O$Z+O$,,,,,,,,,,,,,,,.
,,Z:$,ZOZ,,,,Z,$~$~Z,,,.,$,O,,,,,+?7=Z:Z?,,.,+O+Z?7,,,,,,Z:Z$O7,,,,,,,,,,,,,,,,.
,,$.:~Z,..,.,Z,,,:Z:,,,,,Z~$..,,,Z,Z,Z,Z,,,,,Z=Z$,Z,,,,.,OZ+O:,,,,,,,,,,,,,,,,,.
,~Z?ZZI,,..,I+Z$Z:O,...,??7~,,,,,Z,Z~$=Z,,,,Z:$ZO~$,,,,,,+Z7Z,,,,,,,,,,,,,,,,,,.
~Z~Z$,,,.,,?$:$$$~Z$,,,+$:$Z,,.,ZZ+$ZZ$Z,..ZZZ$,Z?ZZ,,,,,Z7$$,,,,,,,,,,,,,,,,,,.
$$$$Z,,,,,,$Z$$7$Z$Z.,.Z$Z$7,,..$Z$ZZ$:,,.,Z$ZOIZ$$Z..,,?ZZ$O,,,,,,,,,,,,,,,,,,.
...............+?7++ON??+??I?????+8...,..,..............,...,...................
...........,,.~$+?$$8D$++?????????++............................................
.............~+NIZZIO,8?7???++I????+D..............,.......,....................