#Introduction
This is the readme file for Udacity Logs Analysis Project
-
Download and install virtualbox for your operating systems
-
Download and install for your operating systems
-
Clone fullstack-nanodegree-vm
-
Change directory to vagrant folder
-
Run this code to start vagrant
$ vagrant up
$ vagrant ssh
##Getting Started
-
Open logAnalysis folder
-
Run
psql -d news -f newsdata.sql
in terminal to connect to the news database and run newsdata.sql -
Run
python newsdb.py
to setup news database query- Result of the query should appear in the terminal after this
-
Run
python logAnalysis
to Run the site -
Browse the site at http://0.0.0.0:8000/
##Question 1 (Top Article) Top Article Link
select articles.title as title, count(articles.title) as views
from articles inner join log on (log.path='/article/'||articles.slug)
group by title
order by views
desc
limit 3;
##Question 2 (Top Author) Top Author Link
select authors.name as name, count(authors.name) as views
from authors right outer join (articles inner join log on (log.path='/article/'||articles.slug)) as ntable
on (authors.id=ntable.author)
group by name
order by views
desc;
##Question 3 (On which days did more than 1% of requests lead to errors? ) Most Errors Link
- Create a view to organize the data
create view count_table
as select date(time), count(status)
filter (where status='404 NOT FOUND') as nfcount,
count(time) as total_request
from log
group by date(time);
- Get the result by entering this code
select date,
round( cast(float8 (nfcount*100::decimal)/total_request as numeric),2) as error_percentage
from count_table
where round( cast(float8 (nfcount*100::decimal)/total_request as numeric),2) > 1