-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feature implement database #7
Open
raselahmed2k7
wants to merge
18
commits into
master
Choose a base branch
from
feature_implement_database
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+211
−57
Open
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
4e90cc6
Scraping tickets details and all flights information for between two …
raselahmed2k7 9168f83
Ticket details scraping implemented for gettings all tickets information
raselahmed2k7 67bb30e
Refactored code
raselahmed2k7 efeea1d
scraper implementation code refactored for avoiding ajax error issue
raselahmed2k7 2799835
scraping site url line break added
raselahmed2k7 332c148
Removed extra line
raselahmed2k7 95aa9eb
Conflicts resolved
raselahmed2k7 6954db3
DB schema added for scraper data save
raselahmed2k7 0f68d30
DB schema column name updated
raselahmed2k7 5c3820d
Scraping data saving function added, updated schema
raselahmed2k7 442d72d
Migration file added, ticket company table insert query updated
raselahmed2k7 396fdeb
ticket flight company_id, comapny table ticket_summary_id wrong issu…
raselahmed2k7 05e2a20
Added some clean code and comments
raselahmed2k7 f8fbf27
refactoring added, fixed some missing variable issues, request change…
raselahmed2k7 65129c6
Migration file some comments lin added
raselahmed2k7 353e701
Migration file some comments line added
raselahmed2k7 6d04c9c
Migration file some empty line added
raselahmed2k7 46e8053
db column spelling and realted code updated
raselahmed2k7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Migration file added, ticket company table insert query updated
commit 442d72d48eeb4f6dba2491231e022ee274a77144
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
require 'sqlite3' | ||
|
||
db = SQLite3::Database.open "db_tour_scraper.db" | ||
|
||
db.execute <<SQL | ||
CREATE TABLE IF NOT EXISTS tickets_summary ( | ||
id INTEGER PRIMARY KEY AUTOINCREMENT, | ||
departure_date Date, | ||
return_date Date, | ||
time_from_out VARCHAR(20), | ||
time_to_out VARCHAR(20), | ||
search_time DateTime, | ||
total_tickets_out INTEGER, | ||
total_tickets_in INTEGER | ||
); | ||
SQL | ||
|
||
db.execute <<SQL | ||
CREATE TABLE IF NOT EXISTS tickets_airline_companies ( | ||
id INTEGER PRIMARY KEY AUTOINCREMENT, | ||
ticket_summary_id INTEGER, | ||
airline_company_name VARCHAR(100), | ||
ticket_lowest_price FLOAT, | ||
total_flights_available INTEGER, | ||
ticket_type VARCHAR(10), | ||
FOREIGN KEY(ticket_summary_id) REFERENCES tickets_summary(id) | ||
); | ||
SQL | ||
|
||
db.execute <<SQL | ||
CREATE TABLE IF NOT EXISTS airline_flights ( | ||
id INTEGER PRIMARY KEY AUTOINCREMENT, | ||
ticket_airline_id INTEGER, | ||
flight_code VARCHAR(50), | ||
flight_price INTEGER, | ||
flight_changable_status VARCHAR(50), | ||
flight_ticket_type VARCHAR(100), | ||
FOREIGN KEY(ticket_airline_id) REFERENCES tickets_airlines(id) | ||
); | ||
SQL | ||
|
||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,14 +96,14 @@ def save_scrap_data(tickets_out_lists, tickets_in_lists, departure_date, return_ | |
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 commentThe 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 |
||
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, DB.last_insert_row_id(), tickets_out[:ticket_company_name], tickets_out[:ticket_minimum_price], tickets_out[:number_of_ticket_found], 'round_trip']) | ||
DB.execute("INSERT INTO tickets_airline_companies values(?, ?, ?, ?, ?, ?)", [nil, DB.last_insert_row_id(), tickets_out[:ticket_company_name], tickets_out[:ticket_minimum_price], tickets_out[:number_of_ticket_found], 'out']) | ||
tickets_out[:ticket_flight_lists].each do |flight| | ||
DB.execute("INSERT INTO airline_flights values(?, ?, ?, ?, ?, ?)", [nil, DB.last_insert_row_id(), flight['flight_code'], flight['flight_price'], flight['flight_changable_status'], flight['flight_type']]) | ||
end | ||
end | ||
|
||
all_ticket_in_lists.each do |tickets_in| | ||
DB.execute("INSERT INTO tickets_airline_companies values(?, ?, ?, ?, ?, ?)", [nil, ticket_summary_id, tickets_in[:ticket_company_name], tickets_in[:ticket_minimum_price], tickets_in[:number_of_ticket_found], 'round_trip']) | ||
DB.execute("INSERT INTO tickets_airline_companies values(?, ?, ?, ?, ?, ?)", [nil, ticket_summary_id, tickets_in[:ticket_company_name], tickets_in[:ticket_minimum_price], tickets_in[:number_of_ticket_found], 'in']) | ||
tickets_in[:ticket_flight_lists].each do |flight| | ||
DB.execute("INSERT INTO airline_flights values(?, ?, ?, ?, ?, ?)", [nil, DB.last_insert_row_id(), flight['flight_code'], flight['flight_price'], flight['flight_changable_status'], flight['flight_type']]) | ||
end | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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