-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
close #2045 improve adding venue to product admin #2046
Conversation
5f9dc0f
to
cfbf574
Compare
62a6087
to
8407aac
Compare
8213496
to
03c4358
Compare
ba02ac8
to
78332af
Compare
78332af
to
a5c3476
Compare
end | ||
|
||
def collection | ||
@collection ||= begin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the begin statement here cause nested code. let's remove it.
|
||
private | ||
|
||
Place = Struct.new(:id, :name, :base_64_content) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this Struct from global declaration in the controller, it might cause a conflict of type in the future.
context.google_places = [] | ||
json_response = fetch_google_place_by_name | ||
|
||
json_response['results'].each_with_index do |json, _| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use the .map instead.
end | ||
|
||
def fetch_google_place_by_name | ||
url = URI("#{GOOGLE_MAP_API_URL}/place/textsearch/json?query=#{name}&key=#{google_map_key}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't construct the query manually, it is not safe.
queries = {
query: name,
key: google_map_key
}.to_param
google_uri = URI("#{GOOGLE_MAP_API_URL}/place/textsearch/json?#{queries}")
|
||
def fetch_google_place_by_name | ||
url = URI("#{GOOGLE_MAP_API_URL}/place/textsearch/json?query=#{name}&key=#{google_map_key}") | ||
https = Net::HTTP.new(url.host, url.port) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the Faraday instead of the Net. Make sure to keep the Http outbound request consitent by not employing other libs/classes
Place.new( | ||
id: place.reference, | ||
name: place.name, | ||
base_64_content: Base64.strict_encode64(place.to_json) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forget. why do we need the base_64_content for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In form, we can only pass key & value bong. Because we want to pass all google place data, we need to encode it.
In controller, we can decode it back, and create place in database if not yet exist.
7c74577
to
972724c
Compare
972724c
to
e31a208
Compare
Demo :
Screencast.from.2024-11-28.10-10-05.webm
Description :