Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
venshop
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tan Phat Nguyen
venshop
Commits
fbc9fcb1
Commit
fbc9fcb1
authored
Nov 17, 2014
by
Tan Phat Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Amazon get item
parent
c1144e64
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
33 deletions
+30
-33
db/seeds.rb
+1
-1
lib/tasks/db.rake
+29
-32
No files found.
db/seeds.rb
View file @
fbc9fcb1
...
@@ -6,6 +6,6 @@
...
@@ -6,6 +6,6 @@
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
# Mayor.create(name: 'Emanuel', city: cities.first)
%w(Books
Toys
OutdoorLiving Appliances Magazines)
.
each
do
|
category
|
%w(Books
HealthPersonalCare
OutdoorLiving Appliances Magazines)
.
each
do
|
category
|
Category
.
create
(
name:
category
)
Category
.
create
(
name:
category
)
end
end
lib/tasks/db.rake
View file @
fbc9fcb1
...
@@ -17,45 +17,43 @@ namespace :db do
...
@@ -17,45 +17,43 @@ namespace :db do
rg
=
%w(ItemAttributes Images EditorialReview)
.
join
(
','
)
rg
=
%w(ItemAttributes Images EditorialReview)
.
join
(
','
)
categories
=
Category
.
all
categories
=
Category
.
all
var_category
=
{
'Books'
=>
'1000'
,
'
Toys'
=>
'16579301
1'
,
'OutdoorLiving'
=>
'286168'
,
var_category
=
{
'Books'
=>
'1000'
,
'
HealthPersonalCare'
=>
'376093
1'
,
'OutdoorLiving'
=>
'286168'
,
'Appliances'
=>
'2619525011'
,
'Magazines'
=>
'599872'
}
'Appliances'
=>
'2619525011'
,
'Magazines'
=>
'599872'
}
categories
.
each
do
|
category
|
categories
.
each
do
|
category
|
[
1
,
7
].
each
do
|
page_number
|
[
1
,
7
].
each
do
|
page_number
|
@res
=
req
.
item_search
(
query:
{
@res
=
req
.
item_search
(
query:
{
'ItemSearch.Shared.Condition'
=>
'New'
,
'ItemSearch.Shared.Condition'
=>
'New'
,
'ItemSearch.Shared.BrowseNode'
=>
var_category
[
category
.
name
],
'ItemSearch.Shared.BrowseNode'
=>
var_category
[
category
.
name
],
'ItemSearch.Shared.ResponseGroup'
=>
rg
,
'ItemSearch.Shared.ResponseGroup'
=>
'Large'
,
'ItemSearch.SearchIndex'
=>
category
.
name
,
'ItemSearch.SearchIndex'
=>
category
.
name
,
'ItemSearch.1.ItemPage'
=>
page_number
,
'ItemSearch.1.ItemPage'
=>
page_number
,
'ItemSearch.2.ItemPage'
=>
10
'ItemSearch.2.ItemPage'
=>
10
})
})
@add_new
=
[]
@res
=
@res
.
to_h
@res
.
to_h
[
"ItemSearchResponse"
].
to_h
[
"Items"
].
to_a
.
each
do
|
item
|
@res
[
'ItemSearchResponse'
][
'Items'
][
0
][
'Item'
].
each
do
|
item
|
item
.
to_h
[
"Item"
].
to_a
.
each
do
|
value
|
item_product
=
Product
.
new
book_tmp
=
value
.
to_h
puts
item
[
'ItemAttributes'
][
'Title'
]
@add_new
.
push
(
details:
book_tmp
[
'DetailPageURL'
],
image:
book_tmp
[
'LargeImage'
],
item_product
.
name
=
item
[
'ItemAttributes'
][
'Title'
]
item:
book_tmp
[
'ItemAttributes'
],
editor:
book_tmp
[
'EditorialReviews'
])
item_product
.
price
=
item
[
'ItemAttributes'
][
'ListPrice'
][
'FormattedPrice'
][
1
..-
1
]
end
if
item
[
'EditorialReviews'
][
'EditorialReview'
].
kind_of?
(
Array
)
end
item_product
.
description
=
item
[
'EditorialReviews'
][
'EditorialReview'
][
0
][
'Content'
]
@add_new
.
each
do
|
item_res
|
else
item_product
=
Product
.
new
item_product
.
description
=
item
[
'EditorialReviews'
][
'EditorialReview'
][
'Content'
]
item_product
.
name
=
item_res
[
:item
][
'Title'
]
end
if
item_res
[
:item
].
has_key?
(
'ListPrice'
)
if
item
.
has_key?
(
'MediumImage'
)
item_product
.
price
=
item_res
[
:item
][
'ListPrice'
][
'FormattedPrice'
][
1
..-
1
]
#item_product[:remote_photo_url] = item['MediumImage']['URL']
else
else
item_product
.
price
=
item_res
[
:item
][
'TradeInValue'
][
'FormattedPrice'
][
1
..-
1
]
if
item
[
'ImageSets'
][
'ImageSet'
].
kind_of?
(
Array
)
end
#item_product[:remote_photo_url] = item['ImageSets']['ImageSet'][0]['MediumImage']['URL']
if
item_res
[
:editor
][
'EditorialReview'
].
kind_of?
(
Array
)
else
item_product
.
description
=
item_res
[
:editor
][
'EditorialReview'
][
0
][
'Content'
]
#item_product[:remote_photo_url] = item['ImageSets']['ImageSet']['MediumImage']['URL']
else
end
item_product
.
description
=
item_res
[
:editor
][
'EditorialReview'
][
'Content'
]
end
end
category
.
products
<<
item_product
# item_product[:remote_photo_url] = item_res[:image]['URL']
puts
'OK'
category
.
products
<<
item_product
end
puts
'OK'
category
.
save
end
end
end
end
category
.
save
end
end
end
end
end
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment