{"id":18266117,"url":"https://github.com/alexandrabaturina/logs-analysis","last_synced_at":"2025-04-09T01:47:26.805Z","repository":{"id":119258566,"uuid":"247827039","full_name":"alexandrabaturina/logs-analysis","owner":"alexandrabaturina","description":"Reporting tool to analyze data from the database","archived":false,"fork":false,"pushed_at":"2020-07-14T21:43:08.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-14T20:39:24.010Z","etag":null,"topics":["db-api","join-tables","postgresql-database","psycopg2","select-clauses","views"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alexandrabaturina.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-03-16T22:18:12.000Z","updated_at":"2020-09-25T17:06:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"9b048247-779e-453f-8760-a4bcbed6efc3","html_url":"https://github.com/alexandrabaturina/logs-analysis","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexandrabaturina%2Flogs-analysis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexandrabaturina%2Flogs-analysis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexandrabaturina%2Flogs-analysis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexandrabaturina%2Flogs-analysis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexandrabaturina","download_url":"https://codeload.github.com/alexandrabaturina/logs-analysis/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247958722,"owners_count":21024829,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["db-api","join-tables","postgresql-database","psycopg2","select-clauses","views"],"created_at":"2024-11-05T11:21:52.382Z","updated_at":"2025-04-09T01:47:26.799Z","avatar_url":"https://github.com/alexandrabaturina.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Logs Analysis\n## Overview\nThe **logs_analysis.py** is reporting tool to analyze the reader's activity on newspaper site. The database to analyze contains newspaper articles as well as the web server log for the site. The log has a database row for each time a reader loaded a web page.\n\nThe **log_analysis.py** script is written as first assignment of [Full Stack Web Developer Nanodegree Program](https://www.udacity.com/course/full-stack-web-developer-nanodegree--nd0044) provided by Udacity.\n## Features\nThe **logs_analysis.py** script prints out the following information from the **news** database:\n  - Three most popular articles of all time\n  - The most popular article authors of all time\n  - Days when more than 1% of requests lead to errors\n## Getting Started\n### Prerequisites\nTo use LogsAnalysis, the following software and data are required:\n  - *VirtualBox* – software to run the virtual machine. Download from [here](https://www.virtualbox.org/wiki/Download_Old_Builds_5_1)\n  - *Vagrant* – software to configure virtual machine. Download the version for your operating system from [here](https://www.vagrantup.com/downloads.html)\n  - The virtual machine configuration file. Download and unzip [this file](https://s3.amazonaws.com/video.udacity-data.com/topher/2018/April/5acfbfa3_fsnd-virtual-machine/fsnd-virtual-machine.zip)\n  - The *newsdata.sql* file. Download from [here](https://d17h27t6h515a5.cloudfront.net/topher/2016/August/57b5f748_newsdata/newsdata.zip) and unzip\n\n### Starting the Virtual Machine\nChange to the directory containing virtual machine files. Find the **vagrant** directory and change to it. Inside the **vagrant** directory, run the following command.\n```sh\n$ vagrant up\n```\nOnce **vagrant up** is finished running, log in to the virtual machine using the following command.\n```sh\n$ vagrant ssh\n```\n### Loading the Data to the Database\nPlace the unziped *newsdata.sql* file to the **vagrant** directory. To load the data, from the **vagrant** directory, run the following command.\n```sh\n$ psql -d news -f newsdata.sql\n```\n### Creating Views\nIn the terminal, type the following commands to create __errors__ and __total__ views in the database.\n```\n$ create view errors as\n$ select date(time) as time, count(*) as count_errors\n$ from log\n$ where status != '200 OK'\n$ group by date(time);\n```\n```\n$ create view total as\n$ select date(time) as time, count(*) as count_requests\n$ from log\n$ group by date(time);\n```\n## Running\nTo run the script locally,\n1. Clone this repo.\n2. ```cd``` into project directory.\n3. Add execution permission to **logs_analysis.py**.\n```sh\n$ chmod +x logs_analysis.py\n```\n4. Run the script using the command below.\n```sh\n$  python logs_analysis.py\n```\n\nThe results of the **logs_analysis.py** script execution are shown below.\n```sh\nvagrant@vagrant:/vagrant$ python logs_analysis.py\nThree most popular articles:\nCandidate is jerk, alleges rival - 338647 views\nBears love berries, alleges bear - 253801 views\nBad things gone, say good people - 170098 views\n\n\nThe most popular authors:\nUrsula La Multa - 507594 views\nRudolf von Treppenwitz - 423457 views\nAnonymous Contributor - 170098 views\nMarkoff Chaney - 84557 views\n\n\nDays when more than 1% of requests lead to errors:\nJuly 17, 2016 - 2.26%\n```\n## Author\nAlexandra Baturina\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexandrabaturina%2Flogs-analysis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexandrabaturina%2Flogs-analysis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexandrabaturina%2Flogs-analysis/lists"}