Skip to content

PedroBortolli/CFStats

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CFStats - An app to show relevant Codeforces statistics

 

Description

This app was developed using Ruby on Rails. Click here to check it out!

The website is currently running on a free-version of Heroku, so slow connections may happen (bare with us!).

 

Usage example

On the top navbar, type 2 valid Codeforces handles and then click on "Compare!". Another page will be loaded containing information about each individual user and also common information between them. (Note: you can check the box "Force update", telling the website that you want fresh information from both users. The update may take a while (about 30 seconds in the worst cases))

Currently, these are the information available:

  • Rating graph over the time for both users
  • Problems solved by each user (unique and in common)
  • Problems that each user has attempt but failed to solve
  • Contests that both users participated (unique and in common)
  • Problems' tags chart based on solved problems by each user

Another feature of this project is the profile page (requires an account). Click on "Profile" on the index page. There you can add your Codeforces handle, you can add friends, problems and contests to solve later. This feature is still under construction, but it is being developed to be used as some kind of shortcut and as a way to save important Codeforces link to the future.

The cool thing about the profile page is that it communicates to Codeforces API to retrieve which problems/contests you've already solved/attempted. If it detects that one of these links is not relevant to you anymore it suggets the user to delete them. That way you can easly control and optimize your training!

 

Local installation

Click to expand

Alternatively, you can run CFStats locally on your machine.

The first thing to be done is to install some dependencies for Ruby. For this step you must have root privilege. Run the following commands:

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -

echo "deb https://dl.yarnpkg.com/debian/stable main" | \ sudo tee /etc/apt/sources.list . d/yarn.list

sudo apt-get update

sudo apt-get install git-core curl zlib1g-dev build-essential \ libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 \ libxml2-dev libxslt1-dev libcurl4-openssl-dev \ python-software-properties libffi-dev nodejs yarn

 

Now to install Ruby:

cd

git clone https://github.com/rbenv/rbenv.git ~/.rbenv

echo ’export PATH ="$HOME/.rbenv/bin:$PATH"’ >> ~/.bashrc

echo ’eval "$(rbenv init -)"’ >> ~/.bashrc

exec $SHELL

git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build

echo ’export PATH ="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"’ >> ~/.bashrc

exec $SHELL

rbenv install 2.5.0

rbenv global 2.5.0

ruby -v

 

Now to install Rails:

gem install rails -v 5.1.4

rbenv rehash

 

The last thing to do is to install Postgresql. That's the database this app is being built with. Run:

sudo sh -c "echo 'deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main' > /etc/apt/sources.list.d/pgdg.list"

wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -

sudo apt-get update

sudo apt-get install postgresql-common

sudo apt-get install postgresql-9.5 libpq-dev

 

Getting the repository

Once everything is set, clone this repository running:

git clone https://github.com/pedrobortolli/CFStats.git

Navigate to the folder generated by the clone and install the gems dependencies:

bundle install

 

Configuring the database of CFStats (postgres)

Create the db_user user:

sudo -u postgres createuser db_user

 

Open psql menu to write some commands to give the user permissions:

sudo -u postgres psql

postgres=# ALTER USER db_user WITH ENCRYPTED PASSWORD 'db';

postgres=# ALTER USER db_user superuser createrole createdb replication;

postgres=# \q

 

Open /etc/postgresql/9.5/main/pg_hba.conf with root access:

sudo nano /etc/postgresql/9.5/main/pg_hba.conf

 

Change peer to md5 in these lines:

Before changing:

# "local" is for Unix domain socket connections only

local all all peer

# IPv4 local connections:

host all all 127.0.0.1/32 peer

# IPv6 local connections:

host all all ::1/128 peer

 

After your change:

# "local" is for Unix domain socket connections only

local all all md5

# IPv4 local connections:

host all all 127.0.0.1/32 md5

# IPv6 local connections:

host all all ::1/128 md5

 

Save the file with pressing Ctrl-O. Exit nano with Ctrl-X Restart postgresql using:

sudo service postgresql restart

 

Then go to the CFStats cloned directory and run the following commands:

rake db:create

rake db:migrate

 

Running the app server

Navigate to the source folder (type cd src)

Run rails s

That's it! Now the app server is running locally on your computer! To visit the webpage, go to your navigator and type localhost:3000

 

If anything goes wrong

If something goes wrong on the installation phase, perhaps something has changed on the current version of some of the applications we are using. Please go to the respective manuals of those applications to try and find a solution. If anything else goes wrong, please contact us.

 

How to make tests

We have two automized tests for the project:

Run rake test:models to run tests for the models implemented.

Run rake test:controllers to run tests for the controllers implemented.

 

Pull requests and bugs reports

We will be more than glad to hear you! If you find something don't hesitate to tell us. You can create an issue here on GitHub about a bug or feature request. Also, feel free to fork the repository and send us your pull requests!

 

Who works on this project?

About

A web app that consumes Codeforces API to display useful stats, comparison between users, etc

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •