dev_partners
jingquan huang 6 years ago
commit a715d33728

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

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

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

@ -14,10 +14,9 @@
<th width="6%">序号</th>
<th width="10%">ID</th>
<th width="20%" class="edu-txt-left">单位名称</th>
<th width="24%">时段一<br><%= "#{params[:begin_date]}至#{params[:end_date]}" %></th>
<th width="24%">时段二<br><%= "#{params[:other_begin_date]}至#{params[:other_end_date]}" %></th>
<th width="16%" colspan="2">
<%#= sort_tag('变化情况', name: 'percentage', path: school_data_contrast_managements_path) %>
<th width="22%">时段一<br><%= "#{params[:begin_date]}至#{params[:end_date]}" %></th>
<th width="22%">时段二<br><%= "#{params[:other_begin_date]}至#{params[:other_end_date]}" %></th>
<th width="20%" colspan="2">
变化情况
<br> 新 增 数 | 新增百分比)
</th>
@ -31,21 +30,25 @@
<td class="edu-txt-left"><%= report.school_name %></td>
<td><%= report['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;">
+<%= report['increase'] %>
+<%= increase %>
</td>
<td class="edu-txt-left pl20 c_red" style="color: red;">+<%= report['percentage'] %>%</td>
<% elsif report['increase'].zero? %>
<td class="edu-txt-left pl20 c_red" style="color: red;">+<%= percentage.round(5) %>%</td>
<% elsif increase.zero? %>
<td class="edu-txt-right pr20 right-border" style="position: relative;">
<%= report['increase'] %>
<%= increase %>
</td>
<td class="edu-txt-left pl20"><%= report['percentage'] %></td>
<td class="edu-txt-left pl20"><%= percentage.round(5) %>%</td>
<% else %>
<td class="edu-txt-right pr20 right-border c_green" style="position: relative; color: green;">
<%= report['increase'] %>
<%= increase %>
</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 %>
</tr>
<% 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,17 +44,17 @@ if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
}
function removeExceptGitDir(dir) {
fs2.readdir(dir, function(err, list) {
if (err) return done(err);
// readdirSync
const list = fs2.readdirSync(dir)
// if (err) return done(err);
var pending = list.length;
if (!pending) return done(null, results);
// if (!pending) return done(null, results);
list.forEach(function(file) {
if (file.indexOf('.git') == -1) {
file = path.resolve(dir, file);
fs.remove(file)
fs.removeSync(file)
}
});
});
}
// First, read the current file sizes in build directory.
@ -202,6 +202,14 @@ function generateNewIndexJsp() {
fs2.writeFile(outputPath, result, 'utf8', function (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