newest items

This commit is contained in:
Emi Matchu 2011-08-04 10:01:44 -04:00
parent b939c7fce6
commit d99a1ad792
7 changed files with 53 additions and 27 deletions

View file

@ -32,7 +32,10 @@ class ItemsController < ApplicationController
end end
else else
respond_to do |format| respond_to do |format|
format.html { render } format.html {
@newest_items = Item.newest.limit(9)
render
}
format.js { render :json => {:error => '$q required'}} format.js { render :json => {:error => '$q required'}}
end end
end end

View file

@ -38,6 +38,8 @@ class Item < ActiveRecord::Base
"LEFT JOIN #{SwfAsset.table_name} sa ON sa.type = 'object' AND sa.id = psa.swf_asset_id" "LEFT JOIN #{SwfAsset.table_name} sa ON sa.type = 'object' AND sa.id = psa.swf_asset_id"
).where('sa.id IS NULL') ).where('sa.id IS NULL')
scope :newest, order(arel_table[:created_at].desc)
scope :spidered_longest_ago, order(["(#{Item.arel_table[:last_spidered].eq(nil).to_sql}) DESC", arel_table[:last_spidered].desc]) scope :spidered_longest_ago, order(["(#{Item.arel_table[:last_spidered].eq(nil).to_sql}) DESC", arel_table[:last_spidered].desc])
scope :sold_in_mall, where(:sold_in_mall => true) scope :sold_in_mall, where(:sold_in_mall => true)

View file

@ -8,7 +8,7 @@ body.items-index
form form
margin-bottom: 2em margin-bottom: 2em
#search-help #search-info
+main_unit +main_unit
padding-right: 1% padding-right: 1%
dl dl
@ -22,3 +22,4 @@ body.items-index
img img
height: 80px height: 80px
width: 80px width: 80px

View file

@ -13,6 +13,7 @@
= render @items = render @items
= will_paginate @items = will_paginate @items
- else - else
#search-info
#search-help #search-help
%h2 Find what you're looking for %h2 Find what you're looking for
%dl %dl
@ -34,6 +35,10 @@
%dt type:hat %dt type:hat
%dd returns any item that fills a "hat" zone %dd returns any item that fills a "hat" zone
#search-new-items
%h2 Newest items
= render @newest_items
#species-search-links #species-search-links
%h2 Can't decide? Search by species %h2 Can't decide? Search by species
= standard_species_search_links = standard_species_search_links

View file

@ -0,0 +1,13 @@
class AddTimestampsToItems < ActiveRecord::Migration
def self.up
add_timestamps :objects
timestamp_query = "(SELECT created_at FROM contributions WHERE contributed_id = objects.id AND contributed_type = 'Item')"
update "UPDATE objects SET created_at = #{timestamp_query}, updated_at = #{timestamp_query}"
end
def self.down
remove_timestamps :objects
end
end

View file

@ -10,7 +10,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20110731021808) do ActiveRecord::Schema.define(:version => 20110804134432) do
create_table "auth_servers", :force => true do |t| create_table "auth_servers", :force => true do |t|
t.string "short_name", :limit => 10, :null => false t.string "short_name", :limit => 10, :null => false
@ -86,6 +86,8 @@ ActiveRecord::Schema.define(:version => 20110731021808) do
t.text "species_support_ids", :limit => 16777215 t.text "species_support_ids", :limit => 16777215
t.boolean "sold_in_mall", :null => false t.boolean "sold_in_mall", :null => false
t.datetime "last_spidered" t.datetime "last_spidered"
t.datetime "created_at"
t.datetime "updated_at"
end end
add_index "objects", ["last_spidered"], :name => "objects_last_spidered" add_index "objects", ["last_spidered"], :name => "objects_last_spidered"

View file

@ -1638,21 +1638,21 @@ body.items-index form {
margin-bottom: 2em; margin-bottom: 2em;
} }
/* line 11, ../../../app/stylesheets/items/_index.sass */ /* line 11, ../../../app/stylesheets/items/_index.sass */
body.items-index #search-help { body.items-index #search-info {
float: left; float: left;
width: 49%; width: 49%;
padding-right: 1%; padding-right: 1%;
} }
/* line 4, ../../../app/stylesheets/items/_index.sass */ /* line 4, ../../../app/stylesheets/items/_index.sass */
body.items-index #search-help h2 { body.items-index #search-info h2 {
font-size: 125%; font-size: 125%;
} }
/* line 14, ../../../app/stylesheets/items/_index.sass */ /* line 14, ../../../app/stylesheets/items/_index.sass */
body.items-index #search-help dl { body.items-index #search-info dl {
text-align: left; text-align: left;
} }
/* line 16, ../../../app/stylesheets/items/_index.sass */ /* line 16, ../../../app/stylesheets/items/_index.sass */
body.items-index #search-help dd { body.items-index #search-info dd {
margin-bottom: 1em; margin-bottom: 1em;
} }
/* line 19, ../../../app/stylesheets/items/_index.sass */ /* line 19, ../../../app/stylesheets/items/_index.sass */