-
Notifications
You must be signed in to change notification settings - Fork 0
Feature implement database #7
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
base: master
Are you sure you want to change the base?
Conversation
…dates, related code updated
tour_site_scraper.rb
Outdated
| ticket_summary_in&.each do |ticket_cmpany_in| | ||
| puts ticket_cmpany_in.text.to_s + ', ' | ||
| end | ||
| # binding.pry |
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.
Please remove.
tour_site_scraper.rb
Outdated
| puts "Total tickets found for out is = " + total_ticket_out_found.to_s | ||
| puts "Total tickets found for in is = " + total_ticket_in_found.to_s | ||
|
|
||
| DB.execute("INSERT INTO tickets_summary values(?, ?, ?, ?, ?, ?, ?, ? )", [nil, departure_date.to_s, return_date.to_s, TIME_FROM_OUT, TIME_TO_OUT, Time.now.strftime("%Y-%m-%d %H:%M:%S"), total_ticket_out_found, total_ticket_in_found]) |
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.
Please limit to 80 character per line for all. Ref: Ruby Style Guide
tour_site_scraper.rb
Outdated
| DB.execute("INSERT INTO tickets_summary values(?, ?, ?, ?, ?, ?, ?, ? )", [nil, departure_date.to_s, return_date.to_s, TIME_FROM_OUT, TIME_TO_OUT, Time.now.strftime("%Y-%m-%d %H:%M:%S"), total_ticket_out_found, total_ticket_in_found]) | ||
| ticket_summary_id = DB.last_insert_row_id() | ||
| all_ticket_out_lists.each do |tickets_out| | ||
| DB.execute("INSERT INTO tickets_airline_companies values(?, ?, ?, ?, ?, ?)", [nil, ticket_summary_id, tickets_out[:ticket_company_name], tickets_out[:ticket_minimum_price], tickets_out[:number_of_ticket_found], 'out']) |
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.
The same here
tour_site_scraper.rb
Outdated
| flight_data['flight_price'] = ticket_flight.find_elements(:css, '.ticket-detail-item .ticket-detail-item-inner .ticket-price > label > b')[0].attribute("innerHTML") | ||
| flight_data['flight_seat'] = ticket_flight.find_elements(:css, '.ticket-detail-item .ticket-detail-item-inner .ticket-detail-type .ticket-detail-icon .icon-seat')[0].attribute("innerHTML") | ||
| flight_data['flight_changable_status'] = ticket_flight.find_elements(:css, '.ticket-detail-item .ticket-detail-item-inner .ticket-detail-type .ticket-detail-icon .icon-date')[0].attribute("innerHTML") | ||
| flight_data['flight_type'] = ticket_flight.find_elements(:css, '.ticket-detail-item .ticket-detail-item-inner .ticket-detail-type .ticket-detail-type-text .ticket-detail-type-text-ellipsis')[0].attribute("innerHTML") |
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.
80 character per line. Ref: Ruby Style Guide
tour_site_scraper.rb
Outdated
|
|
||
| MAX_RETRY = 100 | ||
| WAIT = Selenium::WebDriver::Wait.new(timeout: 20) | ||
| DB = SQLite3::Database.new( "db_tour_scraper.db" ) |
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.
new("db_tour_scraper.db")
Ref: spaces-and-braces
migration.rb
Outdated
| FOREIGN KEY(ticket_airline_id) REFERENCES tickets_airlines(id) | ||
| ); | ||
| SQL | ||
|
|
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.
Please remove extra new line
tour_site_scraper.rb
Outdated
| Time.now.strftime("%Y-%m-%d %H:%M:%S"), | ||
| total_ticket_out_found, total_ticket_in_found | ||
| ] | ||
| DB.execute("INSERT INTO tickets_summary values(?, ?, ?, ?, ?, ?, ?, ? )", ) |
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.
What are the values it is inserting? Should it use ticket_summary_data in the interpolation!
tour_site_scraper.rb
Outdated
| tickets_out[:number_of_ticket_found], | ||
| 'out' | ||
| ] | ||
| DB.execute("INSERT INTO tickets_airline_companies values(?, ?, ?, ?, ?, ?)", ) |
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.
DB.execute("INSERT INTO tickets_airline_companies values(?, ?, ?, ?, ?, ?)", company_data)
📝 概要 | Summary
This implementation will save scraped data to SQLite database.
🔖 関連URL | Related links
Task link:
https://bitfountain.atlassian.net/jira/software/projects/SCRAPING/boards/9?selectedIssue=SCRAPING-6
Related doc:
https://docs.google.com/presentation/d/1UsAT649j4wdaq_UEjzEZENnVgIJWSWWIcD8RrrRb7FQ/edit#slide=id.g105796642e1_0_0
Database Design Details:
https://bitfountain.atlassian.net/wiki/spaces/GENERAL/pages/292225054/Database+design+details+description
変更点 | Changes
備考 | Remarks
📸 UI変更点 | changes on UI