dev_partners
jingquan huang 6 years ago
commit a715d33728

@ -1152,9 +1152,10 @@ class ApplicationController < ActionController::Base
def user_login_and_from_openi def user_login_and_from_openi
url = request.referer.nil? ? Redmine::Configuration['educoder_domain'] : request.referer url = request.referer.nil? ? Redmine::Configuration['educoder_domain'] : request.referer
flag = URI(url).host == URI(Redmine::Configuration['openi_domain']).host && !current_user.logged? flag = URI(url).host == URI(Redmine::Configuration['openi_domain']).host && !current_user.logged?
logger.info "----------------------- #{url} -------------------------" logger.info "----------------------- request referer: #{request.referer} -------------------------"
logger.info "----------------------- #{URI(url).host} --------------------------" logger.info "----------------------- url after processed: #{url} -------------------------"
logger.info "----------------------- #{flag} -------------------------" logger.info "----------------------- host: #{URI(url).host} --------------------------"
logger.info "----------------------- handle_flag: #{flag} -------------------------"
flag flag
end end
end end

@ -1,5 +1,5 @@
class Managements::BaseController < ApplicationController class Managements::BaseController < ApplicationController
layout 'base_management' layout 'base_management'
before_filter :require_admin before_filter :require_business
end end

@ -24,10 +24,8 @@ class Management::SchoolDataContrastService
reports = reports.where("school_name LIKE :keyword OR school_id LIKE :keyword", keyword: "%#{keyword}%") reports = reports.where("school_name LIKE :keyword OR school_id LIKE :keyword", keyword: "%#{keyword}%")
end end
reports = reports.group(:school_id) count = reports.count('distinct(school_id)')
count = reports.count.count reports = reports.group(:school_id).limit(PAGE_SIZE).offset(offset)
reports = reports.limit(PAGE_SIZE).offset(offset)
[count, reports] [count, reports]
end end
@ -57,9 +55,7 @@ class Management::SchoolDataContrastService
def select_columns def select_columns
"school_id, school_name,"\ "school_id, school_name,"\
"(@total:=SUM(IF(date BETWEEN '#{format_date(params[:begin_date])}' AND '#{format_date(params[:end_date])}', #{contrast_column}, 0))) total,"\ "(SUM(IF(date BETWEEN '#{format_date(params[:begin_date])}' AND '#{format_date(params[:end_date])}', #{contrast_column}, 0))) total,"\
"(@other_total:=SUM(IF(date BETWEEN '#{format_date(params[:other_begin_date])}' AND '#{format_date(params[:other_end_date])}', #{contrast_column}, 0))) other_total,"\ "(SUM(IF(date BETWEEN '#{format_date(params[:other_begin_date])}' AND '#{format_date(params[:other_end_date])}', #{contrast_column}, 0))) other_total"\
"(IF(@other_total - @total = 0, 0.0, round((@other_total - @total) / IF(@total = 0, 1, @total), 5))) percentage,"\
"(@other_total - @total) increase"
end end
end end

@ -14,10 +14,9 @@
<th width="6%">序号</th> <th width="6%">序号</th>
<th width="10%">ID</th> <th width="10%">ID</th>
<th width="20%" class="edu-txt-left">单位名称</th> <th width="20%" class="edu-txt-left">单位名称</th>
<th width="24%">时段一<br><%= "#{params[:begin_date]}至#{params[:end_date]}" %></th> <th width="22%">时段一<br><%= "#{params[:begin_date]}至#{params[:end_date]}" %></th>
<th width="24%">时段二<br><%= "#{params[:other_begin_date]}至#{params[:other_end_date]}" %></th> <th width="22%">时段二<br><%= "#{params[:other_begin_date]}至#{params[:other_end_date]}" %></th>
<th width="16%" colspan="2"> <th width="20%" colspan="2">
<%#= sort_tag('变化情况', name: 'percentage', path: school_data_contrast_managements_path) %>
变化情况 变化情况
<br> 新 增 数 | 新增百分比) <br> 新 增 数 | 新增百分比)
</th> </th>
@ -31,21 +30,25 @@
<td class="edu-txt-left"><%= report.school_name %></td> <td class="edu-txt-left"><%= report.school_name %></td>
<td><%= report['total'] %></td> <td><%= report['total'] %></td>
<td><%= report['other_total'] %></td> <td><%= report['other_total'] %></td>
<% if report['increase'] > 0 %> <%
increase = report['other_total'] - report['total']
percentage = report['total'].zero? ? increase.to_f * 100 : (increase / report['total'].to_f) * 100
%>
<% if increase > 0 %>
<td class="edu-txt-right pr20 right-border" style="position: relative; color: red;"> <td class="edu-txt-right pr20 right-border" style="position: relative; color: red;">
+<%= report['increase'] %> +<%= increase %>
</td> </td>
<td class="edu-txt-left pl20 c_red" style="color: red;">+<%= report['percentage'] %>%</td> <td class="edu-txt-left pl20 c_red" style="color: red;">+<%= percentage.round(5) %>%</td>
<% elsif report['increase'].zero? %> <% elsif increase.zero? %>
<td class="edu-txt-right pr20 right-border" style="position: relative;"> <td class="edu-txt-right pr20 right-border" style="position: relative;">
<%= report['increase'] %> <%= increase %>
</td> </td>
<td class="edu-txt-left pl20"><%= report['percentage'] %></td> <td class="edu-txt-left pl20"><%= percentage.round(5) %>%</td>
<% else %> <% else %>
<td class="edu-txt-right pr20 right-border c_green" style="position: relative; color: green;"> <td class="edu-txt-right pr20 right-border c_green" style="position: relative; color: green;">
<%= report['increase'] %> <%= increase %>
</td> </td>
<td class="edu-txt-left pl20" style="color: green;"><%= report['percentage'] %>%</td> <td class="edu-txt-left pl20" style="color: green;"><%= percentage.round(5) %>%</td>
<% end %> <% end %>
</tr> </tr>
<% end %> <% end %>

@ -0,0 +1,9 @@
class AddIndexToSchoolDailyReports < ActiveRecord::Migration
def change
add_index :school_daily_reports, [:date, :teacher_increase_count]
add_index :school_daily_reports, [:date, :student_increase_count]
add_index :school_daily_reports, [:date, :course_increase_count]
add_index :school_daily_reports, [:date, :shixun_increase_count]
add_index :school_daily_reports, [:date, :active_user_count]
end
end

@ -44,16 +44,16 @@ if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
} }
function removeExceptGitDir(dir) { function removeExceptGitDir(dir) {
fs2.readdir(dir, function(err, list) { // readdirSync
if (err) return done(err); const list = fs2.readdirSync(dir)
var pending = list.length; // if (err) return done(err);
if (!pending) return done(null, results); var pending = list.length;
list.forEach(function(file) { // if (!pending) return done(null, results);
if (file.indexOf('.git') == -1) { list.forEach(function(file) {
file = path.resolve(dir, file); if (file.indexOf('.git') == -1) {
fs.remove(file) file = path.resolve(dir, file);
} fs.removeSync(file)
}); }
}); });
} }
@ -202,6 +202,14 @@ function generateNewIndexJsp() {
fs2.writeFile(outputPath, result, 'utf8', function (err) { fs2.writeFile(outputPath, result, 'utf8', function (err) {
if (err) return console.log(err); if (err) return console.log(err);
commitAndPush();
}); });
}); });
}
function commitAndPush() {
var exec = require('child_process').exec;
function puts(error, stdout, stderr) { console.log(stdout) }
var options = {cwd:"./build"};
exec("git status && git commit -am 'b' && git push", options, puts);
} }
Loading…
Cancel
Save