Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
baya committed Sep 27, 2013
1 parent 29d9a9b commit 263f86e
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
59 changes: 59 additions & 0 deletions ground/db/migrations/006_add_index.rb
Original file line number Diff line number Diff line change
@@ -0,0 1,59 @@
Sequel.migration do
up do
alter_table(:stars) do
add_index :source_id
add_index :name
add_index :description
end

alter_table(:reindex_stars) do
add_index :status
end

alter_table(:q_star_assocs) do
add_index :q
add_index :star_id
add_index :score
add_index [:q, :star_id]
end

alter_table(:dic_stars) do
add_index :star_id
add_index :dic_id
end

alter_table(:dics) do
add_index :word
end

end

down do
alter_table(:stars) do
drop_index :source_id
drop_index :name
drop_index :description
end

alter_table(:reindex_stars) do
drop_index :status
end

alter_table(:q_star_assocs) do
drop_index :q
drop_index :star_id
drop_index :score
drop_index [:q, :star_id]
end

alter_table(:dic_stars) do
drop_index :star_id
drop_index :dic_id
end

alter_table(:dics) do
drop_index :word
end

end
end
22 changes: 22 additions & 0 deletions ground/states/star/save_description.rb
Original file line number Diff line number Diff line change
@@ -0,0 1,22 @@
module Star
class SaveDescription < Ground::State
set :db, Ground.db

def call
db[:stars].where(id: request_payload['id']).update(description: request_payload['description'])
star = db[:stars].where(id: request_payload['id']).first
BuildInvertedStarIndex star: star
json star.to_json
end

private

def request_payload
get_or_set :request_payload do
request.body.rewind
JSON.parse request.body.read
end
end

end
end

0 comments on commit 263f86e

Please sign in to comment.