- Ruby 2.2.4
- Ruby on Rails 4.2.6
- SQLite 3
- SASS, HAML, jQuery
- Sidekiq, Redis
- Nokogiri
- RSpec, FactoryGirl, Faker,...
-
Clone this repo
-
bundle install
-
a.
rake db:create
b.
rake db:migrate
-
brew install redis
redis-server /usr/local/etc/redis.conf
bundle exec sidekiq
rails s
- visit
localhost:3000
for manual testing
-
The server receives a URL from the front-end.
request URL Behavior URL is new create new PageResource and Job objects (status: creating) and push a new job into the Redis queue; send job_id and page_id back to the front-end URL is known and job is still in progress leave it alone URL is known and job was done recently (= today after midnight UTC) create new Job object (status: done) and send job_id, page_id and html to the front-end URL is known and job is outdated (= yesterday before midnight UTC) create new Job object (status: updating), push a job to the Redis queue and send job_id and page_id to the front-end URL is known and the job has failed, but the page can be reached now create new Job object (status: updating), push a job to the Redis queue and send job_id and page_id to the front-end URL is known and the job has failed, but the page can not be reached leave it alone -
The server receives a request for a status update on the jobs:
it looks up the job and returns a status update - including the html if the job is done - to the front-end.
-
The Sidekiq worker handles the scraping of the desired pages in the background and sets the Job status to done.
####Jobs
Column | Datatype |
---|---|
id | integer |
page_resource_id | integer |
jid | sting |
status | integer |
created_at | datetime |
updated_at | datetime |
####PageResources
Column | Datatype |
---|---|
id | integer |
url | sting |
html | text |
statpopularityus | integer |
created_at | datetime |
updated_at | datetime |
So far the app has 60 Rspec tests for the Controllers, Models, Helpers and the Worker. To run them type in your console:
rspec spec/
- The error handeling needs more work
- The front-end could use some polish, but I built it mainly for trouble shooting
- I'd like to spend more time on the Worker test cases
- The view has at the moment no testing at all