From 9886ea48114e04d0e43549506ab6a03f80a87e68 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 19 Jul 2019 16:58:20 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/welcome_controller.rb | 2 +- app/helpers/welcome_helper.rb | 8 ++++---- app/models/user_agent.rb | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 05f04630..c0abee20 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -42,7 +42,7 @@ class WelcomeController < ApplicationController # 运营引流个人数据展示 def user_agents - @user_agents = UserAgent.where(key: params[:edu]) + @user_agents = UserAgent.where(key: params[:edu]).includes(:user_actionss) @agents_count = @user_agents.count limit = 20 @agents_pages = Paginator.new @agents_count, limit, params['page'] || 1 diff --git a/app/helpers/welcome_helper.rb b/app/helpers/welcome_helper.rb index 87d1097d..c6a8d80d 100644 --- a/app/helpers/welcome_helper.rb +++ b/app/helpers/welcome_helper.rb @@ -25,8 +25,8 @@ module WelcomeHelper # 引流注册情况 def register_info user_agent if user_agent.agent_type.to_i == UserAgent::USER_AD - user_id = UserActions.find_by_ip(user_agent.ip).try(:user_id) - if user_id && UserActions.where("user_id = #{user_id} and created_at < '2019-07-15 00:00:00'").present? + user_id = ua.user_actionss.first.try(:user_id) + if user_id && User.where("user_id = #{user_id} and created_on < '2019-07-15 00:00:00'").present? "代理前注册" else "未转换" @@ -34,8 +34,8 @@ module WelcomeHelper elsif user_agent.agent_type.to_i == UserAgent::USER_REGISTER || UserActions.find_by_ip(user_agent.ip) "代理后注册" else - user_id = UserActions.find_by_ip(user_agent.ip).try(:user_id) - if user_id && UserActions.where("user_id = #{user_id} and created_at < '2019-07-15 00:00:00'").present? + user_id = ua.user_actionss.first.try(:user_id) + if user_id && User.where("user_id = #{user_id} and created_on < '2019-07-15 00:00:00'").present? "代理前注册" else "代理后注册" diff --git a/app/models/user_agent.rb b/app/models/user_agent.rb index acc45a8a..3bb16582 100644 --- a/app/models/user_agent.rb +++ b/app/models/user_agent.rb @@ -1,5 +1,5 @@ class UserAgent < ActiveRecord::Base - + has_many :user_actionss, :foreign_key => "ip", :primary_key => "ip" USER_AD = 1 # 广告宣传的引流 USER_REGISTER = 2 # 引流注册 USER_COMPETITION = 3 # 引流参加竞赛 From 9baa72ad5b54186a8dde78153ba8d6bbf75210d9 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 19 Jul 2019 17:02:07 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=8A=A5500?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/welcome_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/welcome_helper.rb b/app/helpers/welcome_helper.rb index c6a8d80d..df7df41c 100644 --- a/app/helpers/welcome_helper.rb +++ b/app/helpers/welcome_helper.rb @@ -25,7 +25,7 @@ module WelcomeHelper # 引流注册情况 def register_info user_agent if user_agent.agent_type.to_i == UserAgent::USER_AD - user_id = ua.user_actionss.first.try(:user_id) + user_id = user_agent.user_actionss.first.try(:user_id) if user_id && User.where("user_id = #{user_id} and created_on < '2019-07-15 00:00:00'").present? "代理前注册" else @@ -34,7 +34,7 @@ module WelcomeHelper elsif user_agent.agent_type.to_i == UserAgent::USER_REGISTER || UserActions.find_by_ip(user_agent.ip) "代理后注册" else - user_id = ua.user_actionss.first.try(:user_id) + user_id = user_agent.user_actionss.first.try(:user_id) if user_id && User.where("user_id = #{user_id} and created_on < '2019-07-15 00:00:00'").present? "代理前注册" else