18F / 2015-foia-hub

A consolidated FOIA request hub.
Other
49 stars 17 forks source link

AgencyObject.stats_set retrieves office data. #813

Open geramirez opened 9 years ago

geramirez commented 9 years ago

I was looking closely at the Stats model and realized that using AgencyObject.stats_set returns the stats from both the Agency and Office. This bug isn't visible because it only affects agencies that have offices and we don't display stats for them.

We can fix the issue by either a quick patch to the API or changing the Stats model to work like the ReadingRoomUrls model. Personally, I rather refactor the Stats model.

khandelwal commented 9 years ago

What is the manifestation of the code? Where do we use stats_set?

geramirez commented 9 years ago

Ok so my bad. This is false alarm. My connect came from this test, which says is testing for both Office and Agency stats but only tests for office stats.

In general, however, we need to be very carful using the Stats model because AgencyObject.stats_set returns the stats for both the AgencyObject and all of its associated offices. I still don't think we should have a model like this but its probably not a priority to change it now.