From c26f0cc3978ecbfa1918a5e64f97619e1ab8aa54 Mon Sep 17 00:00:00 2001 From: "K. Volchenko" Date: Mon, 25 Sep 2017 18:07:20 +0300 Subject: [PATCH] Remove leaderboards (Issue #163) --- apps/web/assets/stylesheets/_leaderboard.scss | 137 ------------------ apps/web/assets/stylesheets/main.scss | 1 - apps/web/config/routes.rb | 2 - apps/web/controllers/leaderboards/index.rb | 19 --- .../templates/leaderboards/index.html.slim | 30 ---- apps/web/views/leaderboards/index.rb | 14 -- .../controllers/leaderboards/index_spec.rb | 21 --- spec/web/views/leaderboards/index_spec.rb | 21 --- 8 files changed, 245 deletions(-) delete mode 100644 apps/web/assets/stylesheets/_leaderboard.scss delete mode 100644 apps/web/controllers/leaderboards/index.rb delete mode 100644 apps/web/templates/leaderboards/index.html.slim delete mode 100644 apps/web/views/leaderboards/index.rb delete mode 100644 spec/web/controllers/leaderboards/index_spec.rb delete mode 100644 spec/web/views/leaderboards/index_spec.rb diff --git a/apps/web/assets/stylesheets/_leaderboard.scss b/apps/web/assets/stylesheets/_leaderboard.scss deleted file mode 100644 index 5706c287..00000000 --- a/apps/web/assets/stylesheets/_leaderboard.scss +++ /dev/null @@ -1,137 +0,0 @@ -/* - * -- TABLET (AND UP) MEDIA QUERIES -- - * On tablets and other medium-sized devices, we want to customize some - * of the mobile styles. - */ -@media (max-width: 48em) { - .leaderboard { - width: 100%; - } -} - -/* - * -- DESKTOP (AND UP) MEDIA QUERIES -- - * On desktops and other large devices, we want to over-ride some - * of the mobile and tablet styles. - */ -@media (min-width: 48em) { - .leaderboard { - width: 700px; - } -} - -.leaderboard { - margin: 2em auto; - - .leaderboard__title { - svg { - display: block; - margin: 0 auto; - } - - h2 { - text-align: center; - } - } - - .leaderboard__switch { - font-size: 0; - text-align: center; - - .leaderboard__switch-item { - font-size: 20px; - display: inline-block; - vertical-align: top; - margin: 0.6em 0; - } - - button.leaderboard__switch-item-link { - } - - .leaderboard__switch-item-link, - .leaderboard__switch-item-link:link, - .leaderboard__switch-item-link:active, - .leaderboard__switch-item-link:visited { - cursor: pointer; - background: none; - display: inline-block; - vertical-align: top; - text-align: center; - font-size: 0.7em; - line-height: 3.28; - text-decoration: none; - border: 1px solid #214CFD; - color: #214CFD; - width: 10.5em; - } - .leaderboard__switch-item-link:hover { - background: #FD2121; - border-color: #FD2121; - color: #fff; - } - .leaderboard__switch-item-link_active, - .leaderboard__switch-item-link_active:hover { - background: #214CFD; - border-color: #214CFD; - color: #fff; - cursor: default; - } - .leaderboard__switch-item:first-child .leaderboard__switch-item-link { - border-radius: 100px 0 0 100px; - } - .leaderboard__switch-item:last-child .leaderboard__switch-item-link { - border-radius: 0 100px 100px 0; - } - } - - .leaderboard__list { - background: #FFFFFF; - box-shadow: 0 0 1px 0 rgba(43, 59, 124, 0.18), 0 1px 3px 0 rgba(43, 59, 125, 0.14); - border-radius: 2px; - margin: 20px 0; - - a:link, - a:active, - a:visited { - color: #214CFD; - } - - .leaderboard__contributors { - } - - .leaderboard__maintainers { - } - } - - .user-row { - padding: 1em 1em; - display: flex; - flex-wrap: wrap; - justify-content: space-between; - - &:hover { - background: #244FFE; - color: #fff; - - a { - color: #fff; - } - } - - .user-row__rank { - margin-right: 1em; - } - - .user-row__name { - flex-grow: 1; - } - - .user-row__avatar { - width: 24px; - height: 24px; - border-radius: 100px; - margin: 0px 0.4em -5px 0; - } - } -} - diff --git a/apps/web/assets/stylesheets/main.scss b/apps/web/assets/stylesheets/main.scss index fe19bf56..64445419 100644 --- a/apps/web/assets/stylesheets/main.scss +++ b/apps/web/assets/stylesheets/main.scss @@ -1,4 +1,3 @@ -@import 'leaderboard'; @import 'settings'; @import 'buttons'; @import 'labels'; diff --git a/apps/web/config/routes.rb b/apps/web/config/routes.rb index 2682006a..a61bdd1d 100644 --- a/apps/web/config/routes.rb +++ b/apps/web/config/routes.rb @@ -1,7 +1,5 @@ root to: 'main#index' -get '/leaderboards', to: 'leaderboards#index' - get '/about', to: 'static#about', as: 'about' get '/how-to-help', to: 'static#help', as: 'help' diff --git a/apps/web/controllers/leaderboards/index.rb b/apps/web/controllers/leaderboards/index.rb deleted file mode 100644 index 54be0eee..00000000 --- a/apps/web/controllers/leaderboards/index.rb +++ /dev/null @@ -1,19 +0,0 @@ -module Web::Controllers::Leaderboards - class Index - include Web::Action - expose :users, :developers, :maintainers - - # TODO: replace to model - def call(params) - @users = UserRepository.new.all_with_points_and_tasks - - @developers = @users.sort do |first, second| - second.points.first&.developer <=> first.points.first&.developer - end - - @maintainers = @users.sort do |first, second| - second.points.first&.maintainer <=> first.points.first&.maintainer - end - end - end -end diff --git a/apps/web/templates/leaderboards/index.html.slim b/apps/web/templates/leaderboards/index.html.slim deleted file mode 100644 index 0c3b7860..00000000 --- a/apps/web/templates/leaderboards/index.html.slim +++ /dev/null @@ -1,30 +0,0 @@ -#js-switcher.leaderboard.main-content - .leaderboard__title - svg height="32px" version="1.1" viewbox=("84 0 32 32") width="32px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" - g#ic_local_bar_black_24px-copy fill="none" fill-rule="evenodd" stroke="none" stroke-width="1" transform="translate(84.000000, 0.000000)" - g#Group - polygon#Shape points=("0 0 32 0 32 32 0 32") - path#Combined-Shape d="M24,5.66666667 C26.209139,5.66666667 28,7.45752767 28,9.66666667 C28,11.8758057 26.209139,13.6666667 24,13.6666667 L24,14.9975267 C24,15.544239 23.6159042,16.2304575 23.1420979,16.5147412 L17.3333333,20 L17.3333333,25.3333333 L24,25.3333333 L24,28 L8,28 L8,25.3333333 L14.6666667,25.3333333 L14.6666667,20 L8.85790207,16.5147412 C8.37753026,16.2265182 8,15.5511774 8,14.9975267 L8,13.6666667 C5.790861,13.6666667 4,11.8758057 4,9.66666667 C4,7.45752767 5.790861,5.66666667 8,5.66666667 L8,4 L24,4 L24,5.66666667 Z M8,7.84848485 C6.99584591,7.84848485 6.18181818,8.66251258 6.18181818,9.66666667 C6.18181818,10.6708208 6.99584591,11.4848485 8,11.4848485 L8,7.84848485 Z M24,7.84848485 C25.0041541,7.84848485 25.8181818,8.66251258 25.8181818,9.66666667 C25.8181818,10.6708208 25.0041541,11.4848485 24,11.4848485 L24,7.84848485 Z" fill="#FBC02D" - - h2 Leaderboard - - .leaderboard__switch - .leaderboard__switch-item - button.leaderboard__switch-item-link v-bind:class="{ 'leaderboard__switch-item-link_active': firstCase }" v-on:click="displayFirstCase" Top contributors - .leaderboard__switch-item - button.leaderboard__switch-item-link v-bind:class="{ 'leaderboard__switch-item-link_active': secondCase }" v-on:click="displaySecondCase" Top maintainers - - .leaderboard__list - .leaderboard__contributors v-if="firstCase" - - developers.each_with_index do |user, i| - .user-row - .user-row__rank = i + 1 - = user_information(user) - .user-row__points = user.points&.first&.developer - - .leaderboard__maintainers v-if="secondCase" - - maintainers.each_with_index do |user, i| - .user-row - .user-row__rank = i + 1 - = user_information(user) - .user-row__points = user.points&.first&.maintainer diff --git a/apps/web/views/leaderboards/index.rb b/apps/web/views/leaderboards/index.rb deleted file mode 100644 index 802e1a1a..00000000 --- a/apps/web/views/leaderboards/index.rb +++ /dev/null @@ -1,14 +0,0 @@ -module Web::Views::Leaderboards - class Index - include Web::View - - def user_information(user) - html.div(class: 'user-row__name') do - a(href: routes.user_path(user.login)) do - img class: 'user-row__avatar', src: user.avatar_url - text(user.login) - end - end - end - end -end diff --git a/spec/web/controllers/leaderboards/index_spec.rb b/spec/web/controllers/leaderboards/index_spec.rb deleted file mode 100644 index c5eae47e..00000000 --- a/spec/web/controllers/leaderboards/index_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require_relative '../../../../apps/web/controllers/leaderboards/index' - -RSpec.describe Web::Controllers::Leaderboards::Index do - let(:action) { described_class.new } - let(:params) { Hash[] } - - it { expect(action.call(params)).to be_success } - - describe 'exposes' do - describe '#users' do - before do - UserRepository.new.create(login: 'anton') - action.call(params) - end - - it 'returns all users' do - expect(action.users).to every(be_an(User)) - end - end - end -end diff --git a/spec/web/views/leaderboards/index_spec.rb b/spec/web/views/leaderboards/index_spec.rb deleted file mode 100644 index 20591668..00000000 --- a/spec/web/views/leaderboards/index_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require_relative '../../../../apps/web/views/leaderboards/index' - -RSpec.describe Web::Views::Leaderboards::Index do - let(:exposures) { Hash[foo: 'bar'] } - let(:template) { Hanami::View::Template.new('apps/web/templates/leaderboards/index.html.slim') } - let(:user) { User.new(id: 1, admin: false, login: 'whatever', avatar_url: 'test_url') } - let(:view) { described_class.new(template, exposures) } - let(:rendered) { view.render } - - describe 'exposes' do - describe '#user_information' do - let(:info) { view.user_information(user) } - - # it { expect(info).to have_css('.user-row__name', count: 1) } - # it { expect(info).to have_css('.user-row__avatar', count: 1) } - # it { expect(info).to have_selector(:css, 'a[href="/users/whatever"]') } - # it { expect(info).to have_selector(:css, 'img[src="test_url"]') } - # it { expect(info).to have_content(user.login, count: 1) } - end - end -end