Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tpi/not active companies #216

Merged
merged 14 commits into from
Jan 30, 2020
Merged

tpi/not active companies #216

merged 14 commits into from
Jan 30, 2020

Conversation

batraisk
Copy link

No description provided.

@@ -21,7 +21,8 @@
<h3>Companies</h3>
<ul>
<% @companies.each do |company| %>
<li><%= link_to company.name, tpi_company_path(company) %></li>
<% company_name = company.is_active ? company.name : "#{company.name} (Not active)" %>
<li><%= link_to company_name, tpi_company_path(company) %></li>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m not sure on which pages to add the inscription "not active" to the name of the companies.
Perhaps it is necessary to create the “name” method in the “company” model so that the inscription appears on all pages?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 maybe move it to view helpers (or decorators for admin pages)?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may need decorators/presenters layer for public interface too, but have to be distinguished from the admin one somehow.

@@ -71,7 +71,7 @@ def user_download_all
end

def user_download
companies_ids = @sector.companies.published.select(:id)
companies_ids = @sector.companies.published.active.select(:id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious - are we sure that scopes published and active are independent of each other? Or maybe inactive companies should be always unpublished?

If those are unrelated we could at least add another scope published_active as it looks those 2 go together at least in this controller.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Active flag is different from the publishable status. So you can have published && inactive companies, and they should still show up on the frontend, just not on all the charts, because an inactive company is a company that is not getting new assessments, but has historical ones. But we could add an extra scope for when we want both published and active if that makes it more clear.

@@ -112,7 +113,7 @@ def companies_scope(params)
TPISector.friendly.find(params[:id]).companies.published
else
Company.published
end
end.active
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This look a bit strange and can be easily overlooked during future changes. If we add published_active scope (see prev comment) we won't need that here :)

@@ -51,6 +51,8 @@ class Company < ApplicationRecord
validates_presence_of :name, :slug, :isin, :market_cap_group
validates_uniqueness_of :slug, :name

scope :active, -> { where(is_active: true) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you also update company factory?

@@ -0,0 +1,5 @@
class AddIsActiveToCompany < ActiveRecord::Migration[6.0]
def change
add_column :companies, :is_active, :boolean, default: true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would vote for not using is_ as a prefix for boolean columns. Just for the sake of consistency with already existing boolean columns in the database. What do you guys think about it?

@simaob simaob requested a review from tsubik January 20, 2020 11:39
@@ -51,6 +52,9 @@ class Company < ApplicationRecord
validates_presence_of :name, :slug, :isin, :market_cap_group
validates_uniqueness_of :slug, :name

scope :active, -> { where(active: true) }
scope :published_active, -> { where(active: true, visibility_status: 'published') }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't really need that scope. We can write Company.published.active

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that my comment goes against @kowal ;]. But I'm not sure what's the point of having extra scopes if we can combine scopes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd keep it simpler and separate scopes as well.

@tsubik
Copy link
Collaborator

tsubik commented Jan 21, 2020

Gonna think of all the places, charts/exporters/importers where the active state needs to be considered.

db/schema.rb Outdated
@@ -247,6 +248,9 @@
create_table "images", force: :cascade do |t|
t.string "link"
t.bigint "content_id", null: false
t.string "name"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea! Those changes are already on develop. WTF

Copy link
Collaborator

@tsubik tsubik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the list of outstanding issues

  • Admin CSV Importer should also update active state, when no value is present then default value is true.
  • Inactive companies not listed in the dropdown as inactive ones. They are gone
  • inactive state not listed on company show page
  • All sectors CP Performance chart data should only consider active companies (right @simaob ?)

@simaob
Copy link
Contributor

simaob commented Jan 24, 2020

@batraisk in case you missed it, Tomasz added a list of outstanding issues here.

db/schema.rb Outdated
@@ -115,6 +116,7 @@
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.string "content_type"
t.string "youtube_link"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some remnants from other branch ;)

Copy link
Collaborator

@tsubik tsubik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One task left to do. I still don't see inactive companies in search. I made Airbus inactive. I can only access the page with knowing URL.

image

@tsubik
Copy link
Collaborator

tsubik commented Jan 30, 2020

@simaob one more thing. Should inactive companies be in All sectors and sector user download?

@simaob
Copy link
Contributor

simaob commented Jan 30, 2020

Might be best to ask on Basecamp.

But if the name says inactive, it could show in the historical files. I think they become inactive when they "drop" them from the most recent assessments

@tsubik
Copy link
Collaborator

tsubik commented Jan 30, 2020

Ok. Let's just leave them there and then we can ask for feedback.

@simaob
Copy link
Contributor

simaob commented Jan 30, 2020

Alright, are the other things sorted? 💃

@tsubik
Copy link
Collaborator

tsubik commented Jan 30, 2020

  • inactive companies shown on pie chart

That's last one.

@tsubik
Copy link
Collaborator

tsubik commented Jan 30, 2020

@batraisk is already working on it.

Copy link
Collaborator

@tsubik tsubik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@tsubik tsubik merged commit 0313816 into develop Jan 30, 2020
@tsubik tsubik deleted the feature/tpi-not-active-companies branch January 30, 2020 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants