From c88e9248436f1ef6186d7cdb4b47dc43ccd58d97 Mon Sep 17 00:00:00 2001 From: txz Date: Fri, 8 Apr 2016 15:31:43 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=8D=9A=E5=AE=A2=E7=95=99=E8=A8=80html?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E8=BD=AC=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/blog_detail.html | 2 +- public/assets/wechat/jour_message_detail.html | 2 +- public/javascripts/wechat/app.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/public/assets/wechat/blog_detail.html b/public/assets/wechat/blog_detail.html index 3c5c30945..823110e54 100644 --- a/public/assets/wechat/blog_detail.html +++ b/public/assets/wechat/blog_detail.html @@ -8,7 +8,7 @@
-
{{blog.content}}
+
{{blog.created_at}} diff --git a/public/assets/wechat/jour_message_detail.html b/public/assets/wechat/jour_message_detail.html index cdc817941..ac0705ac3 100644 --- a/public/assets/wechat/jour_message_detail.html +++ b/public/assets/wechat/jour_message_detail.html @@ -7,7 +7,7 @@
-
{{message.notes}}
+
diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 7a141a6f5..f3c54b0b1 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -10,7 +10,7 @@ app.factory('auth', function($http,$routeParams, $cookies, $q){ var _openid = ''; if(debug===true){ - _openid = "oCnvgv1erQGHzv5GlNZ3sxa2hnSo"; + _openid = "1"; } var getOpenId = function() { From fcddaf403c5f61ce887ee0a78534e3ede736f2e7 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 8 Apr 2016 15:59:23 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=8D=9A=E5=AE=A2?= =?UTF-8?q?=E4=B8=BA=E7=A9=BA=E7=9A=84=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/activities.rb | 21 +++++++++++++ app/api/mobile/apis/new_comment.rb | 2 +- app/api/mobile/entities/activity.rb | 30 +++++++++---------- ...0160408074854_delete_blog_user_activity.rb | 21 +++++++++++++ db/schema.rb | 24 ++++++++++++++- public/javascripts/wechat/app.js | 4 +-- 6 files changed, 83 insertions(+), 19 deletions(-) create mode 100644 db/migrate/20160408074854_delete_blog_user_activity.rb diff --git a/app/api/mobile/apis/activities.rb b/app/api/mobile/apis/activities.rb index 8e4d69738..7d52da6a1 100644 --- a/app/api/mobile/apis/activities.rb +++ b/app/api/mobile/apis/activities.rb @@ -13,6 +13,7 @@ module Mobile end post do user = UserWechat.find_by_openid(params[:openid]).user +=begin shield_project_ids = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Project'").map(&:shield_id) shield_course_ids = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Course'").map(&:shield_id) page = params[:page] ? params[:page] : 0 @@ -27,6 +28,26 @@ module Mobile "or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) "+ "or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{user.id}) " + "or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc') +=end + + shield_project_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{user.id} and shield_type='Project'").map(&:shield_id) + shield_course_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{user.id} and shield_type='Course'").map(&:shield_id) + page = params[:page] ? params[:page] : 0 + user_project_ids = (user.projects.visible.map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (user.projects.visible.map{|project| project.id}-shield_project_ids).join(",") + ")" + user_course_ids = (user.courses.visible.map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (user.courses.visible.map{|course| course.id}-shield_course_ids).join(",") + ")" + course_types = "('Message','News','HomeworkCommon','Poll','Course')" + project_types = "('Message','Issue','ProjectCreateInfo')" + principal_types = "JournalsForMessage" + watched_user_ids = User.watched_by(user.id).count == 0 ? " " : ("," + User.watched_by(user.id).map{|u| u.id.to_s }.join(',')) + user_ids = "(" + user.id.to_s + watched_user_ids + ")" + watched_user_blog_ids = Blog.select("id").where("author_id in #{user_ids}").map { |blog| blog.id}.join(",") + blog_ids = "(" + watched_user_blog_ids + ")" + + activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})" + + "or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) "+ + "or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{user.id}) " + + "or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc') + all_count = activities.count activities = activities.limit(10).offset(page * 10) count = activities.count diff --git a/app/api/mobile/apis/new_comment.rb b/app/api/mobile/apis/new_comment.rb index f7d723090..694ec0613 100644 --- a/app/api/mobile/apis/new_comment.rb +++ b/app/api/mobile/apis/new_comment.rb @@ -23,7 +23,7 @@ module Mobile homework_common = HomeworkCommon.find(params[:id]) feedback = HomeworkCommon.add_homework_jour(current_user, params[:content], params[:id]) if (feedback.errors.empty?) - homework_common.update_attributes(:updated_at => Time.now) + homework_common.update_column(:updated_at, Time.now) result = 2 end when "News" diff --git a/app/api/mobile/entities/activity.rb b/app/api/mobile/entities/activity.rb index e725ed2bb..20876bf69 100644 --- a/app/api/mobile/entities/activity.rb +++ b/app/api/mobile/entities/activity.rb @@ -30,16 +30,14 @@ module Mobile ac.nil? || ac.act.nil? ? 0 : ac.act.journals.where("notes is not null and notes != ''").count end when :subject - unless ac.act.nil? - if ac.act_type == "HomeworkCommon" - ac.act.name unless ac.nil? || ac.act.nil? - elsif ac.act_type == "News" || ac.act_type == "BlogComment" - ac.act.title unless ac.nil? || ac.act.nil? - elsif ac.act_type == "Message" || ac.act_type == "Issue" - ac.act.subject unless ac.nil? || ac.act.nil? - elsif ac.act_type == "JournalsForMessage" - ac.act.private == 0 ? "留言" : "私信" unless ac.nil? || ac.act.nil? - end + if ac.act_type == "HomeworkCommon" + ac.act.name unless ac.nil? || ac.act.nil? + elsif ac.act_type == "News" || ac.act_type == "BlogComment" + ac.act.title unless ac.nil? || ac.act.nil? + elsif ac.act_type == "Message" || ac.act_type == "Issue" + ac.act.subject unless ac.nil? || ac.act.nil? + elsif ac.act_type == "JournalsForMessage" + ac.act.private == 0 ? "留言" : "私信" unless ac.nil? || ac.act.nil? end when :description if ac.act_type == "HomeworkCommon" || ac.act_type == "Issue" || ac.act_type == "News" @@ -135,11 +133,13 @@ module Mobile act_expose :course_project_name #课程/项目名字 act_expose :activity_type_name #课程问答区/项目缺陷等 expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options| - has_praise = false - current_user = options[:user] - obj = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",instance.act_id,instance.act_type.to_s,current_user.id) - has_praise = obj.empty? ? false : true - has_praise + if instance.act_type == "HomeworkCommon" || instance.act_type == "News" || instance.act_type == "Message" || instance.act_type == "BlogComment" || instance.act_type == "JournalsForMessage" || instance.act_type == "Issue" + has_praise = false + current_user = options[:user] + obj = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",instance.act_id,instance.act_type.to_s,current_user.id) + has_praise = obj.empty? ? false : true + has_praise + end end end end diff --git a/db/migrate/20160408074854_delete_blog_user_activity.rb b/db/migrate/20160408074854_delete_blog_user_activity.rb new file mode 100644 index 000000000..6eee78831 --- /dev/null +++ b/db/migrate/20160408074854_delete_blog_user_activity.rb @@ -0,0 +1,21 @@ +class DeleteBlogUserActivity < ActiveRecord::Migration + def up + UserActivity.all.each do |activity| + if activity.act_type == 'BlogComment' + if activity.act + unless activity.act.parent_id.nil? + parent_act = UserActivity.where("act_id = #{activity.act.parent.id} and act_type='BlogComment'").first + parent_act.created_at = activity.act.parent.children.maximum("created_on") + parent_act.save + activity.destroy + end + else + activity.destroy + end + end + end + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 75f316f06..2fd7fd91d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20160317090350) do +ActiveRecord::Schema.define(:version => 20160408074854) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -405,6 +405,8 @@ ActiveRecord::Schema.define(:version => 20160317090350) do t.datetime "updated_at", :null => false end + add_index "course_activities", ["course_id", "course_act_id", "course_act_type", "created_at"], :name => "course_act_index" + create_table "course_attachments", :force => true do |t| t.string "filename" t.string "disk_filename" @@ -465,6 +467,9 @@ ActiveRecord::Schema.define(:version => 20160317090350) do t.integer "status" end + add_index "course_messages", ["course_message_type"], :name => "index_course_messages_on_course_message_type" + add_index "course_messages", ["user_id", "course_id", "created_at"], :name => "index_course_messages_on_user_id_and_course_id_and_created_at" + create_table "course_statuses", :force => true do |t| t.integer "changesets_count" t.integer "watchers_count" @@ -728,6 +733,7 @@ ActiveRecord::Schema.define(:version => 20160317090350) do end add_index "forge_activities", ["forge_act_id"], :name => "index_forge_activities_on_forge_act_id" + add_index "forge_activities", ["project_id", "forge_act_id", "created_at", "forge_act_type"], :name => "forge_act_index" create_table "forge_messages", :force => true do |t| t.integer "user_id" @@ -741,6 +747,9 @@ ActiveRecord::Schema.define(:version => 20160317090350) do t.integer "status" end + add_index "forge_messages", ["forge_message_id", "forge_message_type"], :name => "index_forge_messages_on_forge_message_id_and_forge_message_type" + add_index "forge_messages", ["user_id", "project_id", "created_at"], :name => "index_forge_messages_on_user_id_and_project_id_and_created_at" + create_table "forums", :force => true do |t| t.string "name", :null => false t.text "description" @@ -1055,6 +1064,9 @@ ActiveRecord::Schema.define(:version => 20160317090350) do t.datetime "updated_at", :null => false end + add_index "memo_messages", ["memo_id", "memo_type"], :name => "index_memo_messages_on_memo_id_and_memo_type" + add_index "memo_messages", ["user_id", "forum_id", "created_at"], :name => "index_memo_messages_on_user_id_and_forum_id_and_created_at" + create_table "memos", :force => true do |t| t.integer "forum_id", :null => false t.integer "parent_id" @@ -1078,6 +1090,9 @@ ActiveRecord::Schema.define(:version => 20160317090350) do t.datetime "updated_at", :null => false end + add_index "message_alls", ["message_type"], :name => "index_message_alls_on_message_type" + add_index "message_alls", ["user_id", "message_id", "created_at"], :name => "index_message_alls_on_user_id_and_message_id_and_created_at" + create_table "messages", :force => true do |t| t.integer "board_id", :null => false t.integer "parent_id" @@ -1274,6 +1289,7 @@ ActiveRecord::Schema.define(:version => 20160317090350) do t.datetime "updated_at", :null => false t.string "field_type" t.integer "hide", :default => 0 + t.integer "status", :default => 1 end create_table "organizations", :force => true do |t| @@ -1286,6 +1302,7 @@ ActiveRecord::Schema.define(:version => 20160317090350) do t.datetime "updated_at", :null => false t.boolean "allow_guest_download", :default => true t.integer "visits", :default => 0 + t.integer "show_mode", :default => 0 end create_table "phone_app_versions", :force => true do |t| @@ -1800,6 +1817,8 @@ ActiveRecord::Schema.define(:version => 20160317090350) do t.integer "user_id" end + add_index "user_activities", ["act_id", "act_type", "container_id", "created_at"], :name => "user_act_index" + create_table "user_extensions", :force => true do |t| t.integer "user_id", :null => false t.date "birthday" @@ -1830,6 +1849,9 @@ ActiveRecord::Schema.define(:version => 20160317090350) do t.datetime "updated_at", :null => false end + add_index "user_feedback_messages", ["journals_for_message_id"], :name => "index_user_feedback_messages_on_journals_for_message_id" + add_index "user_feedback_messages", ["user_id", "created_at"], :name => "index_user_feedback_messages_on_user_id_and_created_at" + create_table "user_grades", :force => true do |t| t.integer "user_id", :null => false t.integer "project_id", :null => false diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 7a141a6f5..2e6ceda5c 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -10,7 +10,7 @@ app.factory('auth', function($http,$routeParams, $cookies, $q){ var _openid = ''; if(debug===true){ - _openid = "oCnvgv1erQGHzv5GlNZ3sxa2hnSo"; + _openid = "6"; } var getOpenId = function() { @@ -68,7 +68,7 @@ app.controller('ActivityController',function($scope, $http, auth, rms, common){ console.log("ActivityController load"); $scope.activities = rms.get("activities") || []; - $scope.page = 1; + $scope.page = 0; var loadActData = function(page){ $scope.page = page; From d6daa906b6ddae65d38bafd883ac6cf2708b0dbb Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 8 Apr 2016 16:58:27 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=9B=9E=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1234567 | 1 + app/api/mobile/entities/blog_comment.rb | 4 +++- app/models/blog_comment.rb | 2 +- app/models/journal.rb | 2 +- app/models/journals_for_message.rb | 2 +- public/assets/wechat/blog_detail.html | 2 +- public/javascripts/wechat/app.js | 4 ++-- 7 files changed, 10 insertions(+), 7 deletions(-) create mode 100644 1234567 diff --git a/1234567 b/1234567 new file mode 100644 index 000000000..4354b8b04 --- /dev/null +++ b/1234567 @@ -0,0 +1 @@ +{"access_token":"t3XVpwqZbAO6-uRz_ltKUiplgHcYVstA0p43ECTHEjt0-FvVLU7VXzD7n6Z76PYFWHf8hvNHZtLNAUT-FlTl98wWLIK_lh9mhzHxS_x1iXCc0mC38RjxFzZ_NSeERW7dJZCfADAOEH","expires_in":7200,"got_token_at":1460105603} \ No newline at end of file diff --git a/app/api/mobile/entities/blog_comment.rb b/app/api/mobile/entities/blog_comment.rb index 655050fdd..b11194b30 100644 --- a/app/api/mobile/entities/blog_comment.rb +++ b/app/api/mobile/entities/blog_comment.rb @@ -24,6 +24,8 @@ module Mobile 'BlogComment' when :act_id u.id + when :comment_count + u.children.count end end end @@ -41,7 +43,7 @@ module Mobile blog_comment_expose :blog_id blog_comment_expose :title blog_comment_expose :content - blog_comment_expose :comments_count + blog_comment_expose :comment_count blog_comment_expose :created_at blog_comment_expose :lasted_comment blog_comment_expose :id diff --git a/app/models/blog_comment.rb b/app/models/blog_comment.rb index 0abb6d3d8..945a3c5c2 100644 --- a/app/models/blog_comment.rb +++ b/app/models/blog_comment.rb @@ -99,7 +99,7 @@ class BlogComment < ActiveRecord::Base color:"#173177" }, keyword3:{ - value:h(truncate(key3, :length=>50, :omission=> '...')), + value:self.content.html_safe, color:"#173177" }, remark:{ diff --git a/app/models/journal.rb b/app/models/journal.rb index 8c0bb8f46..b62cf8d97 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -260,7 +260,7 @@ class Journal < ActiveRecord::Base color:"#173177" }, keyword3:{ - value:h(truncate(key3, :length=>50, :omission=> '...')), + value:self.description.html_safe, color:"#173177" }, remark:{ diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 739ef9d8f..82820990f 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -330,7 +330,7 @@ class JournalsForMessage < ActiveRecord::Base color:"#173177" }, keyword3:{ - value:h(truncate(key3, :length=>50, :omission=> '...')), + value:self.notes.html_safe, color:"#173177" }, remark:{ diff --git a/public/assets/wechat/blog_detail.html b/public/assets/wechat/blog_detail.html index 823110e54..92e03ef0c 100644 --- a/public/assets/wechat/blog_detail.html +++ b/public/assets/wechat/blog_detail.html @@ -15,7 +15,7 @@
-
回复 ({{blog.comments_count}})
+
回复 ({{blog.comment_count}})
已赞 ({{blog.praise_count}})
赞 ({{blog.praise_count}})
diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 2e6ceda5c..2b3eaf161 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -1,6 +1,6 @@ var app = angular.module('wechat', ['ngRoute','ngCookies']); var apiUrl = 'http://wechat.trustie.net/api/v1/'; -var debug = false; //调试标志,如果在本地请置为true +var debug = true; //调试标志,如果在本地请置为true if(debug===true){ apiUrl = 'http://localhost:3000/api/v1/'; @@ -10,7 +10,7 @@ app.factory('auth', function($http,$routeParams, $cookies, $q){ var _openid = ''; if(debug===true){ - _openid = "6"; + _openid = "1"; } var getOpenId = function() { From 89330f9e406a6af30f0919050b1d01e25bcf9c0e Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 8 Apr 2016 17:03:48 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/javascripts/wechat/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/javascripts/wechat/app.js b/public/javascripts/wechat/app.js index 2b3eaf161..ddb577285 100644 --- a/public/javascripts/wechat/app.js +++ b/public/javascripts/wechat/app.js @@ -1,6 +1,6 @@ var app = angular.module('wechat', ['ngRoute','ngCookies']); var apiUrl = 'http://wechat.trustie.net/api/v1/'; -var debug = true; //调试标志,如果在本地请置为true +var debug = false; //调试标志,如果在本地请置为true if(debug===true){ apiUrl = 'http://localhost:3000/api/v1/';