Fix who to follow issues
This commit is contained in:
commit
e713710c4c
8 changed files with 30 additions and 14 deletions
|
|
@ -3,7 +3,7 @@ module Api
|
|||
class UsersController < ApplicationController
|
||||
def index
|
||||
if !user_signed_in? || less_than_one_day_old?(current_user)
|
||||
usernames = ["ben", "jess", "peter", "maestromac", "andy", "lianafelt"]
|
||||
usernames = ["ben", "jess", "peter", "maestromac", "andy", "liana"]
|
||||
@users = User.where(username: usernames)
|
||||
return
|
||||
end
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ class ApplicationController < ActionController::Base
|
|||
def after_sign_in_path_for(resource)
|
||||
location = request.env["omniauth.origin"] || stored_location_for(resource) || "/dashboard"
|
||||
context_param = resource.created_at > 40.seconds.ago ? "?newly-registered-user=true" : "?returning-user=true"
|
||||
logger.info("SIGN_IN_FULL_URL: #{location + context_param}")
|
||||
location + context_param
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -74,12 +74,18 @@ class SidebarWidget extends Component {
|
|||
index={index}
|
||||
/>
|
||||
));
|
||||
return (
|
||||
<div className="widget-suggested-follows-container" id="widget-00001">
|
||||
<header>{'<WHO TO FOLLOW>'}</header>
|
||||
<div className="widget-body">{users}</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
if (this.state.suggestedUsers.length > 0) {
|
||||
return (
|
||||
<div className="widget" id="widget-00001">
|
||||
<div className="widget-suggested-follows-container">
|
||||
<header>{'<WHO TO FOLLOW>'}</header>
|
||||
<div className="widget-body">{users}</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return <div />;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,16 +35,17 @@ class UserFollowSuggester
|
|||
|
||||
def sidebar_suggestions(given_tag)
|
||||
Rails.cache.fetch("tag-#{given_tag}_user-#{user.id}-#{user.last_followed_at}/tag-follow-sugggestions", expires_in: 120.hours) do
|
||||
reaction_count = Rails.env.production? ? 25 : 0
|
||||
user_ids = Article.tagged_with([given_tag], any: true).
|
||||
where(
|
||||
"published = ? AND positive_reactions_count > ? AND published_at > ? AND user_id != ?",
|
||||
true, 15, 7.months.ago, user.id
|
||||
).where.not(user_id: user.following_by_type("User").pluck(:id)).pluck(:id)
|
||||
true, reaction_count, 4.months.ago, user.id
|
||||
).where.not(user_id: user.following_by_type("User").pluck(:id)).pluck(:user_id)
|
||||
group_one = User.select(:id, :name, :username, :profile_image).where(id: user_ids).
|
||||
order("reputation_modifier DESC").to_a
|
||||
order("reputation_modifier DESC").limit(20).to_a
|
||||
group_two = User.select(:id, :name, :username, :profile_image).where(id: user_ids).
|
||||
order("RANDOM()").to_a
|
||||
group_one + group_two
|
||||
order("RANDOM()").limit(20).to_a
|
||||
(group_one + group_two).uniq
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -57,8 +57,11 @@
|
|||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if user_signed_in? %>
|
||||
<%= javascript_pack_tag "sidebarWidget", defer: true %>
|
||||
<div class="widget" id="sidebarWidget__pack" data-tag-info="<%= @tag_model.attributes.slice("id", "text_color_hex", "bg_color_hex", "name").to_json %>" />
|
||||
<div id="sidebarWidget__pack" data-tag-info="<%= @tag_model.attributes.slice("id", "text_color_hex", "bg_color_hex", "name").to_json %>">
|
||||
</div>
|
||||
<% end %>
|
||||
<% elsif @query %>
|
||||
<% elsif @podcast_index %>
|
||||
<% else %>
|
||||
|
|
|
|||
|
|
@ -29,6 +29,9 @@
|
|||
<%= Rails.application.assets['index-comments.css'].to_s.html_safe %>
|
||||
<%= Rails.application.assets['footer.css'].to_s.html_safe %>
|
||||
<% end %>
|
||||
<% if @tag_model %>
|
||||
<%= Rails.application.assets['preact/sidebar-widget.css'].to_s.html_safe %>
|
||||
<% end %>
|
||||
</style>
|
||||
<% elsif @notifications_index || @reading_list_items_index %>
|
||||
<style>
|
||||
|
|
|
|||
|
|
@ -4,6 +4,6 @@
|
|||
|
||||
<h1>Are you sure you want to sign out?</h1>
|
||||
|
||||
<h2><%= link_to "Yes. Sign out.", destroy_user_session_path, :method => :delete %></h2>
|
||||
<h2><%= link_to "Yes. Sign out.", destroy_user_session_path, :method => :delete, data: { "no-instant" => "" } %></h2>
|
||||
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ ActiveRecord::Schema.define(version: 20180427160903) do
|
|||
t.boolean "automatically_renew", default: false
|
||||
t.text "body_html"
|
||||
t.text "body_markdown"
|
||||
t.jsonb "boost_states", default: {}, null: false
|
||||
t.boolean "boosted", default: false
|
||||
t.string "cached_tag_list"
|
||||
t.string "cached_user_name"
|
||||
|
|
@ -106,6 +107,7 @@ ActiveRecord::Schema.define(version: 20180427160903) do
|
|||
t.string "video_code"
|
||||
t.string "video_source_url"
|
||||
t.string "video_thumbnail_url"
|
||||
t.index ["boost_states"], name: "index_articles_on_boost_states", using: :gin
|
||||
t.index ["featured_number"], name: "index_articles_on_featured_number"
|
||||
t.index ["hotness_score"], name: "index_articles_on_hotness_score"
|
||||
t.index ["published_at"], name: "index_articles_on_published_at"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue