Git Product home page Git Product logo

cfstats's Introduction

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?

cfstats's People

Contributors

enzohideki avatar jonasarilho avatar pedrobortolli avatar rshimabukuro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

jubayerjoy

cfstats's Issues

Filter bar not working as expected

Although links are being filtered according to the user input, the links are all over the place instead of going up to the list. That means, links are only getting hidden at the list, and not really "deleted"

Speed up some of the API requests

Some of the API requests are running very slow: sometimes it takes up to 10 seconds to retrieve data from Codeforces.
We need to take a look at this and see if we can speed up things.

Enhance ways to add links on /profile page

  • Same thing goes for adding items. Maybe it's good to create an option to add items when the user settles the handle. This should be discussed.
  • Implement a way to add many items (separated by commas) at the same time.

Fix case sensitive on /profile page

Typing Codeforces handles mixing uppercase and lowercase that differ from the original handle lead to possible bugs:
-> The handle shown at the profile page isn't the original. Needs to be.
-> Trying to remove the handle as it is originally isn't possible. Should be (as it should mixing uppercase/lowercase)

Also, when adding problems, the current form only accepts the letter index as uppercase. It should also accept lowercase letters. For example, 939A is accepted but 393a isn't.

No connection bug

When there is no internet connection and you compare 2 handles, it goes "Please provide 2 valid Codeforces handles!".

Add loading box when user hits the update button

On the /result page, whenever an user hits the update info button there should pop up a box containing a simple loading screen. The way it is right now doesn't let the user know whether something is happening or not.

Check devise views

Devise views seem to be bad... error messages are not well formated, for example

Notice user if problem/contest added has already been solved at the /profile page

At the /profile page, the application must talk to the Codeforces API when the user adds a problem/contest to notice (or not) if the problem/contest being added has already been solved. Make sure if the user still wants to add it in case it's been solved.

The same thing should be done when loading the page and there are links in the database already.

Save users' informations to DB every 24 hours

The idea is to make daily API calls for the last 100 users who had their names searched on the website and store the responses on our database.

Also, there should be an "Update now" button on both /result and /profile page in case the user wants their handle informations to be updated instantly. If this button is pressed we make the API calls anyway and warn the user this may take a while (the upper bound seems to be around 15-20 seconds)

That way we can reduce the loading time of /result and /profile pages.

Modify chart at /result page

"Problems by tag" chart shouldn't display so many different tags. Maybe 5 tags or so and then add another label for "Other"

Improve valid handle warning

Improve "Please provide 2 valid Codeforces handles!" warning. Right now, it's an entire page (with only plain text) just for a warning.

Unrated rounds being counted as rated

Unrated codeforces rounds are being counted as normal rated rounds. That means if an user who is supposed to be unrated participated only in unrated rounds, the application gives him rated colors, max up/down rating values, etc.

Fix /result page

The design is a bit messed up...

  • Every row shouldn't be scrollable and their size must be proportional (NOT FIXED!!!!) to the viewer screen size (maybe use vh/vw on CSS to do that?).
  • The last row ("Results") has to center elements.
  • Instead of buttons to show/hide content, make a scrowable list for everything that has a lot of links to be shown. Also, make a search bar to easly filter problems/contests by their names/numbers.

Modify buttons at /result page

Modify all buttons at /result pages. Instead, make scrollable lists of problems/contests with a search box above them to easly filter problems/contests.

First user's resize isn't working

On /result page, when you zoom in and then zoom out, the first user row doesn't get resized properly

image

While the second user is fine

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.