Merge branch 'develop' of https://git.trustie.net/jacknudt/trustieforge into develop
commit
51478bd232
@ -0,0 +1,4 @@
|
|||||||
|
class RepStatics < ActiveRecord::Base
|
||||||
|
belongs_to :project
|
||||||
|
attr_accessible :add, :commits_num, :del, :email, :project_id, :uname, :changeset
|
||||||
|
end
|
@ -0,0 +1,101 @@
|
|||||||
|
//代码查重
|
||||||
|
var homework_id = <%=@homework.id%>;
|
||||||
|
<% if @work_count <= 1 %>
|
||||||
|
//弹框
|
||||||
|
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_2',:locals => {:des=>"对不起该作业的作品过少不能查重!",:status=>0, :homework=> @homework,:courseid=> @course_id})%>');
|
||||||
|
showModal('ajax-modal', '580px');
|
||||||
|
$('#ajax-modal').siblings().remove();
|
||||||
|
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal();' style='margin-left: 565px; margin-top:-10px;' class='resourceClose'></a>");
|
||||||
|
$('#ajax-modal').parent().css("top", "30%").css("left", "50%").css("padding-top", "10px").css("position", "fixed");
|
||||||
|
$('#ajax-modal').parent().addClass("resourceUploadPopup");
|
||||||
|
$('#ajax-modal').css("padding-left", "16px").css("padding-bottom", "16px");
|
||||||
|
|
||||||
|
function closeModal() {
|
||||||
|
hideModal($(".blue-border-box"));
|
||||||
|
}
|
||||||
|
<% else %>
|
||||||
|
<% if !@homework.simi_time %>
|
||||||
|
test_repeat();
|
||||||
|
<% else%>
|
||||||
|
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_1',:locals => {:homework=> @homework,:courseid=>@course_id })%>');
|
||||||
|
$('#compare-tips-1').html('您上次查重的时间为<%= Time.parse(@homework.simi_time.to_s).strftime("%Y-%m-%d %H-%M-%S")%>');
|
||||||
|
showModal('ajax-modal', '580px');
|
||||||
|
$('#ajax-modal').siblings().remove();
|
||||||
|
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal();' style='margin-left: 565px; margin-top:-10px;' class='resourceClose'></a>");
|
||||||
|
$('#ajax-modal').parent().css("top", "30%").css("left", "50%").css("padding-top", "10px").css("position", "fixed");
|
||||||
|
$('#ajax-modal').parent().addClass("resourceUploadPopup");
|
||||||
|
$('#ajax-modal').css("padding-left", "16px").css("padding-bottom", "16px");
|
||||||
|
|
||||||
|
function closeModal() {
|
||||||
|
hideModal($(".blue-border-box"));
|
||||||
|
}
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
//请求查重
|
||||||
|
var test_repeat = function () {
|
||||||
|
$.post(
|
||||||
|
'/student_work/code_repeattest',
|
||||||
|
{homework: homework_id},
|
||||||
|
function (data, status) {
|
||||||
|
if (data.status == 0) {
|
||||||
|
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_2',:locals => {:des=>"查重完成是否立即查看结果?",:status=>1, :homework=> @homework,:courseid=> @course_id})%>');
|
||||||
|
showModal('ajax-modal', '580px');
|
||||||
|
$('#ajax-modal').siblings().remove();
|
||||||
|
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal();' style='margin-left: 565px; margin-top:-10px;' class='resourceClose'></a>");
|
||||||
|
$('#ajax-modal').parent().css("top", "30%").css("left", "50%").css("padding-top", "10px").css("position", "fixed");
|
||||||
|
$('#ajax-modal').parent().addClass("resourceUploadPopup");
|
||||||
|
$('#ajax-modal').css("padding-left", "16px").css("padding-bottom", "16px");
|
||||||
|
|
||||||
|
function closeModal() {
|
||||||
|
hideModal($(".blue-border-box"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (data.status == -1) {
|
||||||
|
// confirm("对不起只支持java/c/c++的代码查重!");
|
||||||
|
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_2',:locals => {:des=>"对不起目前只支持java/c/c++的代码查重!",:status=>0, :homework=> @homework,:courseid=> @course_id})%>');
|
||||||
|
showModal('ajax-modal', '580px');
|
||||||
|
$('#ajax-modal').siblings().remove();
|
||||||
|
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal();' style='margin-left: 565px; margin-top:-10px;' class='resourceClose'></a>");
|
||||||
|
$('#ajax-modal').parent().css("top", "30%").css("left", "50%").css("padding-top", "10px").css("position", "fixed");
|
||||||
|
$('#ajax-modal').parent().addClass("resourceUploadPopup");
|
||||||
|
$('#ajax-modal').css("padding-left", "16px").css("padding-bottom", "16px");
|
||||||
|
|
||||||
|
function closeModal() {
|
||||||
|
hideModal($(".blue-border-box"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (data.status == -2) {
|
||||||
|
// confirm("对不起该作业的作品过少不能查重!");
|
||||||
|
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_2',:locals => {:des=>"对不起该作业的作品过少不能查重!",:status=>0, :homework=> @homework,:courseid=> @course_id})%>');
|
||||||
|
showModal('ajax-modal', '580px');
|
||||||
|
$('#ajax-modal').siblings().remove();
|
||||||
|
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal();' style='margin-left: 565px; margin-top:-10px;' class='resourceClose'></a>");
|
||||||
|
$('#ajax-modal').parent().css("top", "30%").css("left", "50%").css("padding-top", "10px").css("position", "fixed");
|
||||||
|
$('#ajax-modal').parent().addClass("resourceUploadPopup");
|
||||||
|
$('#ajax-modal').css("padding-left", "16px").css("padding-bottom", "16px");
|
||||||
|
|
||||||
|
function closeModal() {
|
||||||
|
hideModal($(".blue-border-box"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
).fail(function (xhr, status) {
|
||||||
|
// confirm("对不起,服务器繁忙请稍后再试!");
|
||||||
|
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'courses/compare_code_tips_2',:locals => {:des=>"对不起,服务器繁忙请稍后再试!",:status=>0, :homework=> @homework,:courseid=> @course_id})%>');
|
||||||
|
showModal('ajax-modal', '580px');
|
||||||
|
$('#ajax-modal').siblings().remove();
|
||||||
|
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal();' style='margin-left: 565px; margin-top:-10px;' class='resourceClose'></a>");
|
||||||
|
$('#ajax-modal').parent().css("top", "30%").css("left", "50%").css("padding-top", "10px").css("position", "fixed");
|
||||||
|
$('#ajax-modal').parent().addClass("resourceUploadPopup");
|
||||||
|
$('#ajax-modal').css("padding-left", "16px").css("padding-bottom", "16px");
|
||||||
|
|
||||||
|
function closeModal() {
|
||||||
|
hideModal($(".blue-border-box"));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,14 @@
|
|||||||
|
class CreateRepStatics < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :rep_statics do |t|
|
||||||
|
t.integer :project_id
|
||||||
|
t.integer :commits_num
|
||||||
|
t.string :uname
|
||||||
|
t.string :email
|
||||||
|
t.integer :add
|
||||||
|
t.integer :del
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,5 @@
|
|||||||
|
class AddChangesetToRepStatics < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :rep_statics, :changeset, :integer
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,26 @@
|
|||||||
|
class SyncRepStatics < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
g = Gitlab.client
|
||||||
|
# projects = Project.find_by_sql("SELECT p.* FROM projects p, project_scores ps where p.id = ps.project_id and p.gpid is not null and ps.changeset_num > 0")
|
||||||
|
projects = Project.where("gpid is not null")
|
||||||
|
count = projects.count / 30 + 2
|
||||||
|
transaction do
|
||||||
|
for i in 1 ... count do i
|
||||||
|
projects.page(i).per(30).each do |project|
|
||||||
|
begin
|
||||||
|
puts project.id
|
||||||
|
g.rep_stats(project.gpid).each do |static|
|
||||||
|
puts static.uname
|
||||||
|
RepStatics.create(:project_id => project.id, :uname => static.uname, :commits_num => static.commits_num, :email => static.email, :add => static.add, :del => static.del, :changeset => static.changes)
|
||||||
|
end
|
||||||
|
rescue
|
||||||
|
logger.error("Sync rep failed!")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,11 @@
|
|||||||
|
FactoryGirl.define do
|
||||||
|
factory :rep_static, :class => 'RepStatics' do
|
||||||
|
project_id 1
|
||||||
|
commits_num 1
|
||||||
|
uname "MyString"
|
||||||
|
email "MyString"
|
||||||
|
add 1
|
||||||
|
del 1
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
@ -0,0 +1,5 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe RepStatics, :type => :model do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
Loading…
Reference in new issue