Skip to content

Commit

Permalink
Revert "New landing page section: Recently added categories"
Browse files Browse the repository at this point in the history
  • Loading branch information
colszowka authored Feb 26, 2019
1 parent 8b1328a commit 38642a7
Show file tree
Hide file tree
Showing 21 changed files with 9 additions and 205 deletions.
1 change: 0 additions & 1 deletion app/assets/stylesheets/application.css.sass
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ $widescreen: 1152px + (2 * $gap)
$navbar-breakpoint: $widescreen

@import "bulma/bulma"
@import "bulma-tooltip/dist/css/bulma-tooltip"
@import "components/**/*"

.border-bottom
Expand Down
2 changes: 0 additions & 2 deletions app/assets/stylesheets/components/category_card.sass
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
.category-cards
&.four
@extend .column, .is-half, .is-one-quarter-desktop, .is-flex
&.three
@extend .column, .is-half, .is-one-third-desktop, .is-flex
&.two
@extend .column, .is-full, .is-half-desktop, .is-flex

Expand Down
23 changes: 0 additions & 23 deletions app/controllers/trends_controller.rb

This file was deleted.

1 change: 0 additions & 1 deletion app/controllers/welcome_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
class WelcomeController < ApplicationController
def home
@featured_categories = Category.featured
@new_categories = Category.recently_added
@stats = Stats.new
@recent_posts = BlogController::BLOG.recent_posts.presence
end
Expand Down
5 changes: 2 additions & 3 deletions app/helpers/component_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,8 @@ def project_comparison(projects)
render "components/project_comparison", projects: projects
end

def section_heading(title, description: nil, help_path: nil, &block)
help_page = docs.find help_path
render "components/section_heading", title: title, description: description, help_page: help_page, &block
def section_heading(title, description: nil, &block)
render "components/section_heading", title: title, description: description, &block
end

def project_display_picker(display_mode)
Expand Down
1 change: 0 additions & 1 deletion app/models/category.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class Category < ApplicationRecord

scope :by_rank, -> { where.not(rank: nil).order(rank: :asc) }
scope :featured, -> { by_rank.limit(16).includes(:projects) }
scope :recently_added, -> { order(created_at: :desc).limit(4).includes(:projects) }

include PgSearch
pg_search_scope :search_scope,
Expand Down
16 changes: 0 additions & 16 deletions app/models/rubygem_download_stat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,8 @@ class RubygemDownloadStat < ApplicationRecord
foreign_key: :rubygem_name,
inverse_of: :download_stats

has_one :project, through: :rubygem

def self.monthly(base_date: RubygemDownloadStat.maximum(:date))
where("(#{table_name}.date <= ?)", base_date)
.where("(#{table_name}.date - ?) % 28 = 0", base_date)
end

def self.with_associations
includes(:rubygem, :project)
.joins(:rubygem, :project)
end

def self.trending
where.not(relative_change_month: nil, growth_change_month: nil) # Stats need to be present xD
.where("relative_change_month < ?", 1000) # "Too high" growth happens usually with very new gems
.where("absolute_change_month > ?", 10_000) # Baseline minimum downloads to be considered "trending"
.where("growth_change_month > ?", 0) # Month-over-month growth must be positive to be trending
.where("rubygems.latest_release_on > ?", 6.months.ago) # Must have had a recent release
.order("growth_change_month DESC NULLS LAST")
end
end
4 changes: 0 additions & 4 deletions app/views/components/_section_heading.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
.level-item
h3.is-size-4
span= title
- if help_page
.level_item
a.button href=page_path(help_page.id) title=help_page.title
span.icon: i.fa.fa-question-circle
.level-right
.level-item= yield

Expand Down
6 changes: 0 additions & 6 deletions app/views/layouts/application.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@ html.has-navbar-fixed-top lang="en"
span.icon: i.fa.fa-arrows-h
span Compare

a.navbar-item href=trends_path class=active_when(controller: :trends)
.wrap
span.icon: i.fa.fa-line-chart
span Trends

a.navbar-item href=page_path("docs/index") class=active_when(controller: :pages)
.wrap
span.icon: i.fa.fa-life-ring
Expand All @@ -102,7 +97,6 @@ html.has-navbar-fixed-top lang="en"
ul
li= link_to "Home", root_path
li= link_to "Categories", categories_path
li= link_to "Trends", trends_path
li= link_to "Documentation", page_path("docs/index")
li= link_to "News", blog_index_path
li= link_to "Search", search_path
Expand Down
3 changes: 1 addition & 2 deletions app/views/pages/components/section_heading.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

= component_example "Section Headings" do
= section_heading "Some title"
= section_heading "Can reference help pages", help_path: "docs/features/categories"
= section_heading "Some title", description: "Some optional description", help_path: "docs/features/categories"
= section_heading "Some title", description: "Some optional description"
= section_heading "Some title", description: "Some optional description" do
a.button href="#"
span.icon: i.fa.fa-diamond
Expand Down
35 changes: 0 additions & 35 deletions app/views/trends/show.html.slim

This file was deleted.

16 changes: 2 additions & 14 deletions app/views/welcome/home.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ section.section: .container: .landing-features
This gives you a quick overview of the health of a project.

- if @featured_categories.any?
section.section.popular-categories: .container
section.section: .container
/ - description = t(:stats, scope: :startpage, projects_with_categories: @stats.projects_with_categories_count, categories: @stats.categories_count, rubygems: @stats.rubygems_count)
= section_heading "Popular Categories", help_path: "docs/features/categories" do
= section_heading "Popular Categories" do
a.button href=categories_path
span.icon: i.fa.fa-bars
span Browse all categories
Expand All @@ -72,15 +72,3 @@ section.section: .container: .landing-features
- @featured_categories.each do |category|
.category-cards.four
= category_card category

- if @new_categories.any?
section.section.recently-added-categories: .container
= section_heading "Recently Added Categories", help_path: "docs/features/categories"
a.button href=categories_path
span.icon: i.fa.fa-bars
span Browse all categories

.columns.is-multiline
- @new_categories.each do |category|
.category-cards.four
= category_card category
7 changes: 3 additions & 4 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@

# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
Rails.application.routes.draw do
resources :blog, only: %i[index show], constraints: { id: /[^\.]+/ }
resources :categories, only: %i[index show]

resources :projects, only: %i[show], constraints: { id: Patterns::ROUTE_PATTERN }
resources :projects, only: %i[show], constraints: { id: Patterns::ROUTE_PATTERN } do
end
get "compare(/:id)", to: "comparisons#show", constraints: { id: /.*/ }, as: :comparison
resources :trends, only: %i[index show]

resource :search, only: %i[show] do
collection do
get :by_name
end
end
resources :blog, only: %i[index show], constraints: { id: /[^\.]+/ }

namespace :webhooks do
post "github", to: "github#create", defaults: { formats: :json }
Expand Down

This file was deleted.

7 changes: 0 additions & 7 deletions db/migrate/20190226090403_add_categories_rank_index.rb

This file was deleted.

18 changes: 1 addition & 17 deletions db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -416,13 +416,6 @@ CREATE UNIQUE INDEX categorizations_unique_index ON public.categorizations USING
CREATE INDEX index_categories_on_category_group_permalink ON public.categories USING btree (category_group_permalink);


--
-- Name: index_categories_on_created_at; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_categories_on_created_at ON public.categories USING btree (created_at);


--
-- Name: index_categories_on_description_tsvector; Type: INDEX; Schema: public; Owner: -
--
Expand All @@ -444,13 +437,6 @@ CREATE INDEX index_categories_on_name_tsvector ON public.categories USING gin (n
CREATE UNIQUE INDEX index_categories_on_permalink ON public.categories USING btree (permalink);


--
-- Name: index_categories_on_rank; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_categories_on_rank ON public.categories USING btree (rank);


--
-- Name: index_categorizations_on_category_permalink; Type: INDEX; Schema: public; Owner: -
--
Expand Down Expand Up @@ -691,8 +677,6 @@ INSERT INTO "schema_migrations" (version) VALUES
('20190207133425'),
('20190211104231'),
('20190218131324'),
('20190220133053'),
('20190226090240'),
('20190226090403');
('20190220133053');


1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"private": false,
"dependencies": {
"bulma": "^0.7.0",
"bulma-tooltip": "^2.0.2",
"chart.js": "^2.7.3",
"headroom.js": "^0.9.4",
"javascript-autocomplete": "^1.0.3"
Expand Down
31 changes: 0 additions & 31 deletions spec/controllers/trends_controller_spec.rb

This file was deleted.

7 changes: 0 additions & 7 deletions spec/controllers/welcome_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@
expect(assigns(:featured_categories)).to be collection
end

it "assigns new categories" do
collection = Category.limit(3)
allow(Category).to receive(:recently_added).and_return(collection)
do_request
expect(assigns(:new_categories)).to be collection
end

it "assigns a Stats instance" do
stats = instance_double Stats
allow(Stats).to receive(:new).and_return(stats)
Expand Down
18 changes: 0 additions & 18 deletions spec/models/category_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,24 +56,6 @@
end
end

describe ".recently_added" do
before do
5.times do |i|
Category.create! permalink: (i + 1).to_s, name: (i + 1).to_s, category_group: group, created_at: i.days.ago
end
end

it "returns 4 newest categories" do
expect(Category.recently_added.pluck(:permalink)).to be == %w[1 2 3 4]
end

it "eager-loads projects" do
query = -> { Category.recently_added.flat_map { |category| category.projects.map(&:permalink) } }
query.call # warm-up, so activerecord doesn't sprinkle in db schema meta queries
expect(&query).to make_database_queries(count: 2)
end
end

describe "#catalog_show_url" do
it "is the url where the category definition can be seen on github" do
expected = "https://github.com/rubytoolbox/catalog/tree/master/catalog/unimportant/mocking.yml"
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
# yarn lockfile v1


bulma-tooltip@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/bulma-tooltip/-/bulma-tooltip-2.0.2.tgz#cf0bf5ad2dc75492cbcbd4816e1a005314dc90ac"
integrity sha512-xsqWeWV7tsUn3uH04SqJeP7/CyC1RaDVIyVzr4/sIO3friIIOi7L6jc5g7qUwDxuBQl72yH/yRPuefpXoQ4hWg==

bulma@^0.7.0:
version "0.7.2"
resolved "https://registry.yarnpkg.com/bulma/-/bulma-0.7.2.tgz#8e944377b74c7926558830d38d8e19eaf49f5fb6"
Expand Down

0 comments on commit 38642a7

Please sign in to comment.