educode_sales 0.3.0 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2a5096eaa908019932cbddf41165f340d93ee6e1
4
- data.tar.gz: 23d6bbd33db8cf4e9a7ebcd675f930b502ae14f6
3
+ metadata.gz: 286cc2bc6fe4b139e0be58e6d1ed40db0ecc253c
4
+ data.tar.gz: 147fed374517bff319fcf9b389b48b84559ec1a3
5
5
  SHA512:
6
- metadata.gz: 6c30ed5b195123de8a120d43d76e7b26a4dedaeb6211e1a09cc75bd28132456b4eed0f6e0ffc0af3bd0ca1915ea3ec3ca1275ae9da70702601b8bed7b05103f0
7
- data.tar.gz: bcb870fe68cc291d0e3c1fcf46f3bc2d6ca05858670cdffd5ae3788e47a18a03e92a80baec0ce5ea1ad7d15ee268ffc9fa6eb0362231601cc5122f314b42b39c
6
+ metadata.gz: a12544c3040b935cbaecd392963f6aa06303b1f2d423a42e1d0bc4dd9ed79e5903f0714af90b22059179bda38ac21e0067af95d720d97a3be283f79020ee85cc
7
+ data.tar.gz: 6c6614e0910b25315a0370f085bab17eb0c867198f93c7c85b14a22f435278f19d448793b13af6039d0781e5d55075166fa6cbc06886d72132b0f6561d7bbbcd
@@ -98,13 +98,19 @@ module EducodeSales
98
98
  end
99
99
 
100
100
  if params[:activity_id].present? && params[:user_id].present?
101
+ @teacher_id = EducodeSales::Teacher.find_by(name: params[:name]).id
102
+
101
103
  # 把老师添加到活动列表,提取判断下老师列表是否存在
102
104
  find_teacher = Teacher.find_by(user_id: params[:user_id])
103
105
  if find_teacher
104
106
  teacher = find_teacher
105
107
  end
106
108
  end
107
- teacher.activity_teachers.build(activity_id: params[:activity_id])
109
+ if params[:activity_id].present?
110
+ return render json: {msg: '该教师已在活动中', success: false } if teacher.activity_teachers.find_by(activity_id: params[:activity_id]).present?
111
+ teacher.activity_teachers.build(activity_id: params[:activity_id])
112
+ end
113
+
108
114
  if teacher.save
109
115
  render_success
110
116
  else
@@ -2,5 +2,7 @@ module EducodeSales
2
2
  class ActivityTeacher < ApplicationRecord
3
3
  belongs_to :activity, counter_cache: true
4
4
  belongs_to :teacher, counter_cache: true
5
+
6
+ validates :teacher_id, uniqueness: {scope: :activity_id, message: '已存在'}
5
7
  end
6
8
  end
@@ -14,19 +14,25 @@ module EducodeSales
14
14
  validates :user_id, uniqueness: { allow_blank: true, message: '已存在老师列表'}
15
15
 
16
16
 
17
+ # def teacher_used_of_department
18
+ # if user_id.present?
19
+ # user_ids = User.joins(:user_extension).where(user_extensions: {department_id: self.department_id, identity: 0}).pluck(:id)
20
+ # course_ids = CourseMember.where(role: "CREATOR", user_id: user_ids).pluck(:course_id)
21
+ # if course_ids.present?
22
+ # course_members = CourseMember.joins(course: :practice_homework_shixuns).where(course_id: course_ids).group("course_id").having("COUNT(homework_commons_shixuns.id) > 100 AND COUNT(course_members.user_id) > 20").select("COUNT(case when course_members.role !=4 then 1 END) AS count")
23
+ # course_members.present? ? course_members[0]['count'] : 0
24
+ # else
25
+ # 0
26
+ # end
27
+ # else
28
+ # 0
29
+ # end
30
+ # end
17
31
  def teacher_used_of_department
18
- if user_id.present?
19
32
  user_ids = User.joins(:user_extension).where(user_extensions: {department_id: self.department_id, identity: 0}).pluck(:id)
20
33
  course_ids = CourseMember.where(role: "CREATOR", user_id: user_ids).pluck(:course_id)
21
- if course_ids.present?
22
- course_members = CourseMember.joins(course: :practice_homework_shixuns).where(course_id: course_ids).group("course_id").having("COUNT(homework_commons_shixuns.id) > 100 AND COUNT(course_members.user_id) > 20").select("COUNT(case when course_members.role !=4 then 1 END) AS count")
23
- course_members.present? ? course_members[0]['count'] : 0
24
- else
25
- 0
26
- end
27
- else
28
- 0
29
- end
34
+ course_members = CourseMember.joins(course: :practice_homework_shixuns).where(course_id: course_ids).group("course_id").having("COUNT(homework_commons_shixuns.id) > 100 AND COUNT(course_members.user_id) > 20").select("COUNT(case when course_members.role !=4 then 1 END) AS count")
35
+ course_members.present? ? course_members[0]['count'] : 0
30
36
  end
31
37
 
32
38
  def students_count
@@ -118,12 +118,12 @@
118
118
  },
119
119
  {
120
120
  field: 'rate',
121
- width: 100,
121
+ width: 80,
122
122
  title: '完成率',
123
123
  },
124
124
  {
125
125
  field: 'updated_at',
126
- width: 150,
126
+ width: 170,
127
127
  title: '更新时间',
128
128
  sort: true,
129
129
  },
@@ -130,7 +130,7 @@
130
130
  },
131
131
  {
132
132
  title: '操作',
133
- minWidth: 150,
133
+ minWidth: 190,
134
134
  toolbar: '#currentMonthly',
135
135
  align: "center"
136
136
  }
@@ -130,7 +130,7 @@
130
130
  },
131
131
  {
132
132
  title: '操作',
133
- minWidth: 150,
133
+ minWidth: 190,
134
134
  toolbar: '#currentWeekly',
135
135
  align: "center"
136
136
  }
@@ -9,7 +9,7 @@ json.data do
9
9
  json.contact EducodeSales::Common.find_by(id: d.follow_id).name
10
10
  json.staff d.staff.user.real_name
11
11
  json.students_count d.students_count
12
- json.courses_count d.courses_count
12
+ json.courses_count Course.joins(:course_members).where(course_members: {user_id: d.teacher&.user_id}).distinct("course_id").count
13
13
  json.evaluates_count d.evaluates_count
14
14
  json.course_shixuns_count d.course_shixuns_count
15
15
  json.shixuns_count d.shixuns_count
@@ -2,7 +2,7 @@
2
2
  <html>
3
3
 
4
4
  <head>
5
- <title><%= @title || 'Educode sales' %></title>
5
+ <title><%= @title || '头歌营销系统' %></title>
6
6
  <%= csrf_meta_tags %>
7
7
  <%= csp_meta_tag %>
8
8
  <%= favicon_link_tag "educode_sales/favicon.ico" %>
@@ -1,3 +1,3 @@
1
1
  module EducodeSales
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: educode_sales
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - anke1460