Skip to content

This project aims to generate an analysis report from a news website database

Notifications You must be signed in to change notification settings

littlecloud1/news-logs-analysis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Author: Lai Man Tang

Github: https://github.com/littlecloud1/news-logs-analysis

Date: 2018-8-16

Project

This project aims to analysis the 'news' database and get the results of :

  1. the most popular three articles of all time
  2. the most popular article authors of all time
  3. the day that has more than 1% of requests lead to errors

Requirements

To Run this program, you have to install following softwares:

  • Python3
  • PostgreSQL
  • psycopg2

Files

This project includes two codes file: news-report.py, newsdb.py and a output file: newsreport.txt

news-report.py: the main function to call the database and output the result into newsreort file.

newsdb.py: it connects to the 'news' database and get the result from the queries.

newsreport.txt: it is a example report that contains three analysis results

Build Setup

You need to download newsdata.sql and import it into database newsdata.sql

# Import Database:
psql -d news -f newsdata.sql

Before running this project you have to create a view inside the datebase:

CREATE VIEW articlesLog AS
SELECT au.name AS author,
       a.title,
       l.id AS logID,
       l.status AS logStatus
FROM log AS l,
      articles AS a,
      authors AS au
WHERE l.path LIKE CONCAT('%/', a.slug) 
      AND au.id = a.author;

How to run

python news-report.py

About

This project aims to generate an analysis report from a news website database

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages