Changeset 80844
- Timestamp:
- 07/18/11 15:37:51 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/gsoc11-statistics/stats-server/app/models/submission.rb
r80746 r80844 18 18 19 19 # Try to find an existing entry 20 os_stats = OsStatistic.find_by_user_id(user.id)20 os_stats = user.os_statistic 21 21 22 22 if os_stats.nil? … … 43 43 logger.debug {"Adding installed port #{installed_port['name']}"} 44 44 45 # Update any ports found for this user is they have already been submitted this month 46 port_entry = InstalledPort.find_by_port_id_and_user_id_and_month_and_year(macports_port.id, 47 user.id, 48 month, 49 year) 50 51 # New port entry 45 # Update any ports found for this user if they have already been submitted this month 46 port_entrys = user.installed_ports.where(:created_at => (Date.today.at_beginning_of_month)..(Date.today.at_end_of_month)) 47 port_entry = port_entrys.find_by_port_id(macports_port.id) 48 49 # No existing entry was found - create a new one 52 50 if port_entry.nil? 53 51 port_entry = InstalledPort.new 54 52 end 55 53 56 54 port_entry[:user_id] = user.id 57 55 port_entry[:port_id] = macports_port.id 58 56 port_entry[:version] = installed_port['version'] 59 57 port_entry[:variants] = installed_port['variants'] 60 port_entry[:month] = month 61 port_entry[:year] = year 62 58 63 59 if not port_entry.save 64 60 logger.debug "Unable to save port #{installed_port['name']}"
Note: See TracChangeset
for help on using the changeset viewer.

