amelialin / logs-analysis

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

logs-analysis

This script generates a report of top articles, authors, and error trends of a news site from the local news database. Results are saved to a plaintext file output.txt.

Requirements

Setup

  1. Clone this repository.
  2. Download newsdata.sql into the same directory.
  3. Run psql -d news -f newsdata.sql to load the data into the news database.

Usage

To generate the report, run:

    $ python3 news.py

Output will be saved to output.txt in the same directory.

Example

Running:

    $ python3 news.py

Outputs:

    Connecting to database...
    Connection successful...
    Querying for top articles...
    Querying for top authors...
    Querying for top error days...
    Connection closed...
    Writing to output.txt...
    Writing complete. All done!

...And generates a plaintext file output.txt in the same directory:

    1. TOP ARTICLES
    What are the most popular three articles of all time? Which articles have been accessed the most?

    "Candidate Is Jerk, Alleges Rival" - 338,647 views
    "Bears Love Berries, Alleges Bear" - 253,801 views
    "Bad Things Gone, Say Good People" - 170,098 views

    2. TOP AUTHORS
    Who are the most popular article authors of all time?

    Ursula La Multa - 507,594 views
    Rudolf von Treppenwitz - 423,457 views
    Anonymous Contributor - 170,098 views
    Markoff Chaney - 84,557 views

    3. TOP ERROR DAYS
    On which days did more than 1% of requests lead to errors?

    July 17, 2016 - 2.3% errors

About

This project is part of Udacity's Full Stack Web Developer Nanodegree. Please do not submit this work as your own.

About


Languages

Language:Python 100.0%