Everything was working perfectly. I ran a few tests this morning in
development and found a few errors and corrected them.
Another thing I did was clear out “old data” in 4 tables. 3 of these
tables are now having the same issue using the following query:
week_start_date =Time.now.beginning_of_week.to_date.strftime(’%Y-%m-%d’)
week_end_date = Time.now.end_of_week.to_date.strftime(’%Y-%m-%d’)
compiled_on = week_start_date…week_end_date
tsos_offense = Team.find(teamone,teamtwo, :joins => [:tsos_offenses],
:conditions => {:tsos_offenses => {:compiled_on => compiled_on}}, :order
=> “teams.id”)
The SQL statement in development.log shows the following:
SELECT teams
.* FROM teams
INNER JOIN tsos_offenses
ON tsos_offenses.team_id = teams.id
WHERE (teams
.id
IN (10,1) AND (tsos_offenses
.compiled_on
BETWEEN
‘2009-08-03’ AND ‘2009-08-09’))
ORDER BY teams.id
It was working perfectly before today.
If I do the following:
week_start_date =Time.now.beginning_of_week.to_date.strftime(’%Y-%m-%d’)
week_end_date = Time.now.end_of_week.to_date.strftime(’%Y-%m-%d’)
compiled_on = week_start_date…week_end_date
tsos_offense = Team.find(10,1, :select => “tsos_offenses.totoff AS
totoff, tsos_offenses.rushoff AS rushoff, tsos_offenses.passoff AS
passoff, tsos_offenses.scoroff AS scoroff, tsos_offenses.rzonoff AS
rzonoff, tsos_offenses.fumlost AS fumlost, tsos_offenses.passhint AS
passhint, tsos_offenses.tolost AS tolost, tsos_offenses.sacksall AS
sacksall, tsos_offenses.tackflossall AS tackflossall,
tsos_offenses.passeff AS passeff, tsos_offenses.firdwns AS firdwns,
tsos_offenses.thrdwncon AS thrdwncon, tsos_offenses.fthdwncon AS
fthdwncon, tsos_offenses.totals AS totals”, :joins => [:tsos_offenses],
:conditions => {:tsos_offenses => {:compiled_on => compiled_on}}, :order
=> “teams.id”)
It works perfectly again. All I’m doing is placing a select into the
query. Why would it change behavior like this in one day? I haven’t
even touched this model and the only thing I did was clear out the old
table data and replace it with new table data. The compiled_on dates
match up perfectly.
The only reasoning I can think about is that there isn’t data “beyond”
this week but why would that matter? The compiled_on is checking for
data between 2009-08-03 and 2009-08-09.
The compiled_on column in tsos_offenses table shows 2009-08-03. I’m a
bit confused as to why I have to use select and specify every column in
the table instead of a simple joins statement…
Any ideas what the problem might be?