Skip to content

Conversation

@raselahmed2k7
Copy link
Contributor

@raselahmed2k7 raselahmed2k7 commented Dec 14, 2021

📝 概要 | 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

⚠️ 影響範囲 | Potential impacts

Page Operation

📸 UI変更点 | changes on UI

image

@raselahmed2k7 raselahmed2k7 marked this pull request as ready for review December 15, 2021 09:36
ticket_summary_in&.each do |ticket_cmpany_in|
puts ticket_cmpany_in.text.to_s + ', '
end
# binding.pry

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove.

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])

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

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'])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same here

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")
Copy link

@mdmahmudurrahman mdmahmudurrahman Dec 15, 2021

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


MAX_RETRY = 100
WAIT = Selenium::WebDriver::Wait.new(timeout: 20)
DB = SQLite3::Database.new( "db_tour_scraper.db" )

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

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

Time.now.strftime("%Y-%m-%d %H:%M:%S"),
total_ticket_out_found, total_ticket_in_found
]
DB.execute("INSERT INTO tickets_summary values(?, ?, ?, ?, ?, ?, ?, ? )", )

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!

tickets_out[:number_of_ticket_found],
'out'
]
DB.execute("INSERT INTO tickets_airline_companies values(?, ?, ?, ?, ?, ?)", )
Copy link

@mdmahmudurrahman mdmahmudurrahman Dec 15, 2021

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants