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
c1144e64
Commit
c1144e64
authored
Nov 17, 2014
by
Tan Phat Nguyen
Committed by
Tan Phat Nguyen
Nov 17, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dev Amazon get data
parent
9a67c835
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
66 additions
and
7 deletions
+66
-7
Gemfile.lock
+2
-2
app/assets/images/fallback/default_photo.png
+0
-0
app/controllers/amazon_controller.rb
+2
-2
app/uploaders/image_uploader.rb
+8
-0
app/views/amazon/index.html.erb
+2
-0
app/views/amazon/welcome.html.erb
+0
-2
db/seeds.rb
+1
-1
lib/tasks/db.rake
+51
-0
No files found.
Gemfile.lock
View file @
c1144e64
...
@@ -135,7 +135,7 @@ GEM
...
@@ -135,7 +135,7 @@ GEM
actionpack (>= 3.0.0)
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
activesupport (>= 3.0.0)
kgio (2.9.2)
kgio (2.9.2)
listen (2.
7.11
)
listen (2.
8.0
)
celluloid (>= 0.15.2)
celluloid (>= 0.15.2)
rb-fsevent (>= 0.9.3)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
rb-inotify (>= 0.9)
...
@@ -220,7 +220,7 @@ GEM
...
@@ -220,7 +220,7 @@ GEM
responders (2.0.2)
responders (2.0.2)
railties (>= 4.2.0.alpha, < 5)
railties (>= 4.2.0.alpha, < 5)
ruby-progressbar (1.7.0)
ruby-progressbar (1.7.0)
sass (3.4.
7
)
sass (3.4.
8
)
sass-rails (5.0.0.beta1)
sass-rails (5.0.0.beta1)
railties (>= 4.0.0, < 5.0)
railties (>= 4.0.0, < 5.0)
sass (~> 3.2)
sass (~> 3.2)
...
...
app/assets/images/fallback/default_photo.png
0 → 100644
View file @
c1144e64
122 KB
app/controllers/amazon_controller.rb
View file @
c1144e64
...
@@ -31,9 +31,9 @@ params = {
...
@@ -31,9 +31,9 @@ params = {
rg
=
%w(ItemAttributes Images EditorialReview)
.
join
(
','
)
rg
=
%w(ItemAttributes Images EditorialReview)
.
join
(
','
)
@res
=
req
.
item_search
(
query:
{
@res
=
req
.
item_search
(
query:
{
'ItemSearch.Shared.SearchIndex'
=>
'All'
,
'ItemSearch.Shared.SearchIndex'
=>
'All'
,
'ItemSearch.Shared.Keywords'
=>
'
Grow Rich
'
,
'ItemSearch.Shared.Keywords'
=>
'
*
'
,
'ItemSearch.Shared.ResponseGroup'
=>
rg
,
'ItemSearch.Shared.ResponseGroup'
=>
rg
,
'ItemSearch.SearchIndex'
=>
'
Toy
s'
,
'ItemSearch.SearchIndex'
=>
'
Book
s'
,
'ItemSearch.1.ItemPage'
=>
1
,
'ItemSearch.1.ItemPage'
=>
1
,
'ItemSearch.2.ItemPage'
=>
2
'ItemSearch.2.ItemPage'
=>
2
})
})
...
...
app/uploaders/image_uploader.rb
View file @
c1144e64
...
@@ -23,6 +23,14 @@ class ImageUploader < CarrierWave::Uploader::Base
...
@@ -23,6 +23,14 @@ class ImageUploader < CarrierWave::Uploader::Base
%w(jpg jpeg gif png)
%w(jpg jpeg gif png)
end
end
version
:thumb
do
process
:resize_to_fill
=>
[
140
,
140
]
end
def
default_url
"fallback/"
+
[
thumb
,
"default_photo.png"
].
compact
.
join
(
'_'
)
end
# Provide a default URL as a default if there hasn't been a file uploaded:
# Provide a default URL as a default if there hasn't been a file uploaded:
# def default_url
# def default_url
# # For Rails 3.1+ asset pipeline compatibility:
# # For Rails 3.1+ asset pipeline compatibility:
...
...
app/views/amazon/index.html.erb
View file @
c1144e64
...
@@ -3,4 +3,5 @@
...
@@ -3,4 +3,5 @@
<h2>
Count:
<%=
@result
.
length
%>
</h2>
<h2>
Count:
<%=
@result
.
length
%>
</h2>
<h2>
Add_new:
<%=
@add_new
.
length
%>
</h2>
<h2>
Add_new:
<%=
@add_new
.
length
%>
</h2>
<%=
@ret
%>
<br>
<%=
@ret
%>
<br>
<h2>
Item 0:
</h2>
<%=
@add_new
%>
<%=
@add_new
%>
\ No newline at end of file
app/views/amazon/welcome.html.erb
View file @
c1144e64
<h1>
Amazon#welcome
</h1>
<h1>
Amazon#welcome
</h1>
<p>
Find me in app/views/amazon/welcome.html.erb
</p>
<p>
Find me in app/views/amazon/welcome.html.erb
</p>
<%=
@res
.
to_h
%>
db/seeds.rb
View file @
c1144e64
...
@@ -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
Clothing DVD Magazine
)
.
each
do
|
category
|
%w(Books Toys
OutdoorLiving Appliances Magazines
)
.
each
do
|
category
|
Category
.
create
(
name:
category
)
Category
.
create
(
name:
category
)
end
end
lib/tasks/db.rake
View file @
c1144e64
...
@@ -7,5 +7,55 @@ namespace :db do
...
@@ -7,5 +7,55 @@ namespace :db do
def
import_products
def
import_products
puts
'Call import_products method'
puts
'Call import_products method'
req
=
Vacuum
.
new
req
.
configure
(
aws_access_key_id:
'AKIAI4FGZR4YFCAP4DVQ'
,
aws_secret_access_key:
'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'
,
associate_tag:
'tag'
)
rg
=
%w(ItemAttributes Images EditorialReview)
.
join
(
','
)
categories
=
Category
.
all
var_category
=
{
'Books'
=>
'1000'
,
'Toys'
=>
'165793011'
,
'OutdoorLiving'
=>
'286168'
,
'Appliances'
=>
'2619525011'
,
'Magazines'
=>
'599872'
}
categories
.
each
do
|
category
|
[
1
,
7
].
each
do
|
page_number
|
@res
=
req
.
item_search
(
query:
{
'ItemSearch.Shared.Condition'
=>
'New'
,
'ItemSearch.Shared.BrowseNode'
=>
var_category
[
category
.
name
],
'ItemSearch.Shared.ResponseGroup'
=>
rg
,
'ItemSearch.SearchIndex'
=>
category
.
name
,
'ItemSearch.1.ItemPage'
=>
page_number
,
'ItemSearch.2.ItemPage'
=>
10
})
@add_new
=
[]
@res
.
to_h
[
"ItemSearchResponse"
].
to_h
[
"Items"
].
to_a
.
each
do
|
item
|
item
.
to_h
[
"Item"
].
to_a
.
each
do
|
value
|
book_tmp
=
value
.
to_h
@add_new
.
push
(
details:
book_tmp
[
'DetailPageURL'
],
image:
book_tmp
[
'LargeImage'
],
item:
book_tmp
[
'ItemAttributes'
],
editor:
book_tmp
[
'EditorialReviews'
])
end
end
@add_new
.
each
do
|
item_res
|
item_product
=
Product
.
new
item_product
.
name
=
item_res
[
:item
][
'Title'
]
if
item_res
[
:item
].
has_key?
(
'ListPrice'
)
item_product
.
price
=
item_res
[
:item
][
'ListPrice'
][
'FormattedPrice'
][
1
..-
1
]
else
item_product
.
price
=
item_res
[
:item
][
'TradeInValue'
][
'FormattedPrice'
][
1
..-
1
]
end
if
item_res
[
:editor
][
'EditorialReview'
].
kind_of?
(
Array
)
item_product
.
description
=
item_res
[
:editor
][
'EditorialReview'
][
0
][
'Content'
]
else
item_product
.
description
=
item_res
[
:editor
][
'EditorialReview'
][
'Content'
]
end
# item_product[:remote_photo_url] = item_res[:image]['URL']
category
.
products
<<
item_product
puts
'OK'
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