diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 84ceacd26..aa25d0875 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -165,9 +165,10 @@ class ShixunsController < ApplicationController def show_right owner = @shixun.owner - #@fans_count = owner.fan_count - #@followed_count = owner.follow_count @user_own_shixuns = owner.shixuns.published.count + @user_tags = @shixun.user_tags_name(current_user) + @shixun_tags = @shixun.challenge_tags_name + @myshixun = @shixun.myshixuns.find_by(user_id: current_user.id) end # 排行榜 @@ -345,7 +346,11 @@ class ShixunsController < ApplicationController #合作者 def collaborators @user = current_user - @members = @shixun.shixun_members.includes(:user) + ## 分页参数 + page = params[:page] || 1 + limit = params[:limit] || 10 + @member_count = @shixun.shixun_members.count + @members = @shixun.shixun_members.includes(:user).page(page).per(limit) end def fork_list diff --git a/app/models/curriculum.rb b/app/models/curriculum.rb new file mode 100644 index 000000000..6c25a5883 --- /dev/null +++ b/app/models/curriculum.rb @@ -0,0 +1,2 @@ +class Curriculum < ApplicationRecord +end diff --git a/app/models/knowledge_point.rb b/app/models/knowledge_point.rb new file mode 100644 index 000000000..f5abbb54e --- /dev/null +++ b/app/models/knowledge_point.rb @@ -0,0 +1,3 @@ +class KnowledgePoint < ApplicationRecord + belongs_to :curriculum +end diff --git a/app/models/knowledge_point_container.rb b/app/models/knowledge_point_container.rb new file mode 100644 index 000000000..ea73d00e7 --- /dev/null +++ b/app/models/knowledge_point_container.rb @@ -0,0 +1,3 @@ +class KnowledgePointContainer < ApplicationRecord + belongs_to :knowledge_point +end diff --git a/app/views/shixuns/_right.json.jbuilder b/app/views/shixuns/_right.json.jbuilder index e6f839aa5..751172701 100644 --- a/app/views/shixuns/_right.json.jbuilder +++ b/app/views/shixuns/_right.json.jbuilder @@ -13,11 +13,17 @@ json.recommands do json.partial! 'shap_shixun', locals: { shixuns: shixun.relation_path.size > 0 ? recommend_shixun(shixun) : [] } end +if shixun.status > 1 + json.complete_count @myshixun&.passed_count + json.challenge_count @shixun.challenges_count +end + # 技能标签 -user_tags = shixun.user_tags_name(User.current) json.tags do - json.array! shixun.challenge_tags_name do |tag| + json.array! @shixun_tags do |tag| json.tag_name tag - json.status user_tags.include?(tag) + json.status @user_tags.include?(tag) end end +json.tag_count @shixun_tags.size +json.user_tag_count @user_tags.size diff --git a/app/views/shixuns/collaborators.json.jbuilder b/app/views/shixuns/collaborators.json.jbuilder index e5f612dba..9a8b8c374 100644 --- a/app/views/shixuns/collaborators.json.jbuilder +++ b/app/views/shixuns/collaborators.json.jbuilder @@ -6,7 +6,8 @@ # ] -json.array! @members do |member| +json.member_count @member_count +json.members @members do |member| json.user do json.partial! 'users/user', locals: { user: member.user } json.user_shixuns_count member.user.shixuns.published.count diff --git a/app/views/shixuns/show_right.json.jbuilder b/app/views/shixuns/show_right.json.jbuilder index fe3c5d0f5..694bd4e7d 100644 --- a/app/views/shixuns/show_right.json.jbuilder +++ b/app/views/shixuns/show_right.json.jbuilder @@ -1,6 +1,6 @@ json.partial! 'shixuns/right', locals: { shixun: @shixun } -json.follow follow?(@shixun.owner, User.current) -json.fans_count @fans_count -json.followed_count @followed_count +# json.follow follow?(@shixun.owner, User.current) +# json.fans_count @fans_count +# json.followed_count @followed_count json.user_shixuns_count @user_own_shixuns diff --git a/db/migrate/20191217100300_create_curriculums.rb b/db/migrate/20191217100300_create_curriculums.rb new file mode 100644 index 000000000..10eb516d5 --- /dev/null +++ b/db/migrate/20191217100300_create_curriculums.rb @@ -0,0 +1,9 @@ +class CreateCurriculums < ActiveRecord::Migration[5.2] + def change + create_table :curriculums do |t| + t.string :name + + t.timestamps + end + end +end diff --git a/db/migrate/20191217102106_create_knowledge_points.rb b/db/migrate/20191217102106_create_knowledge_points.rb new file mode 100644 index 000000000..7e0220c81 --- /dev/null +++ b/db/migrate/20191217102106_create_knowledge_points.rb @@ -0,0 +1,10 @@ +class CreateKnowledgePoints < ActiveRecord::Migration[5.2] + def change + create_table :knowledge_points do |t| + t.references :curriculum, foreign_key: true + t.string :name + + t.timestamps + end + end +end diff --git a/db/migrate/20191217102414_create_knowledge_point_containers.rb b/db/migrate/20191217102414_create_knowledge_point_containers.rb new file mode 100644 index 000000000..32f92f3e5 --- /dev/null +++ b/db/migrate/20191217102414_create_knowledge_point_containers.rb @@ -0,0 +1,11 @@ +class CreateKnowledgePointContainers < ActiveRecord::Migration[5.2] + def change + create_table :knowledge_point_containers do |t| + t.integer :container_id + t.string :container_type + t.references :knowledge_point, foreign_key: true + + t.timestamps + end + end +end diff --git a/spec/models/curriculum_spec.rb b/spec/models/curriculum_spec.rb new file mode 100644 index 000000000..b03089a91 --- /dev/null +++ b/spec/models/curriculum_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Curriculum, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/knowledge_point_container_spec.rb b/spec/models/knowledge_point_container_spec.rb new file mode 100644 index 000000000..3e151062f --- /dev/null +++ b/spec/models/knowledge_point_container_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe KnowledgePointContainer, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/knowledge_point_spec.rb b/spec/models/knowledge_point_spec.rb new file mode 100644 index 000000000..d85138a0f --- /dev/null +++ b/spec/models/knowledge_point_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe KnowledgePoint, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end