Skip to content

dzlatic/udacity

Repository files navigation

Project: Logs Analysis @ Udacity Full Stack Nanodegree

This is a reporting project for a newspaper site, with the database behind it. The exact task is to generate following three reports:

  1. The most popular three articles of all time
  2. The most popular article authors of all time
  3. Days when more than 1% of requests lead to errors

Included files

File Comment
logs-analysis.py python code
Vagrantfile Vagrant configuration file
README.md this file
output.txt expected run output

Dependencies

Software Version Download
Python 3.6.6 link
VirtualBox 5.2.16 link
Vagrant 2.1.2 link

Setup and run instructions:

  1. Download database from this link

  2. Start virtual machine with command:

    vagrant up

  3. Connect to virtial machine with command:

    vagrant ssh

  4. Move to the working directory:

    vagrant@vagrant:/vagrant/logs-analysis$ cd /vagrant

  5. Load data with command:

    vagrant@vagrant:/vagrant/logs-analysis$ psql -d news -f newsdata.sql

  6. Check the database includes following three tables:

Table Content
authors information about the authors of articles
articles the news articles
log includes one entry for each time a user has accessed the site
  1. In PSQL prompt execute following SQL command to create the first helper view:

    CREATE VIEW path_slug AS

    SELECT DISTINCT log.path as path, articles.slug as slug

    FROM log, articles

    WHERE position(articles.slug in log.path) > 0

  2. In PSQL prompt execute following SQL command to create a second helper view:

    CREATE VIEW article_stat AS

    SELECT articles.id as id, count(log.path) as count

    FROM log, path_slug, articles

    WHERE articles.slug = path_slug.slug AND

    path_slug.path = log.path

    GROUP BY articles.id

  3. Run the project code by executing following command on operting system prompt:

    vagrant@vagrant:/vagrant/logs-analysis$ python3 logs-analysis.py

  4. Compare the output with the content of output.txt file.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published