Commit 1d581db8 by Bui Minh Duc

push repo

parent 821d7250
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.0', '>= 5.0.0.1'
# Use sqlite3 as the database for Active Record
......@@ -33,26 +32,30 @@ gem 'mysql2', '~> 0.4.5'
gem 'bootstrap-sass', '~> 3.3.6'
gem 'octokit', '~> 4.6', '>= 4.6.2'
gem 'will_paginate', '~> 3.1', '>= 3.1.5'
gem 'bootstrap-select-rails', '~> 1.6', '>= 1.6.3'
gem 'will_paginate', '~> 3.1', '>= 3.1.5'
gem 'bootstrap-table-rails', '~> 1.11'
gem 'momentjs-rails', '>= 2.9.0'
gem 'bootstrap3-datetimepicker-rails', '~> 4.14.30'
gem 'whenever', '~> 0.9.7'
gem 'redcarpet', '~> 3.3', '>= 3.3.4'
gem 'bootstrap-growl-rails'
gem 'redcarpet', '~> 3.3', '>= 3.3.4'
gem 'rubocop', '~> 0.46.0'
gem 'sidekiq', '~> 4.2', '>= 4.2.7'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platform: :mri
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console'
gem 'listen', '~> 3.0.5'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'web-console'
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
......
......@@ -41,6 +41,7 @@ GEM
addressable (2.5.0)
public_suffix (~> 2.0, >= 2.0.2)
arel (7.1.4)
ast (2.3.0)
autoprefixer-rails (6.6.0)
execjs
bootstrap-growl-rails (3.1.3)
......@@ -102,6 +103,9 @@ GEM
mini_portile2 (~> 2.1.0)
octokit (4.6.2)
sawyer (~> 0.8.0, >= 0.5.3)
parser (2.3.3.1)
ast (~> 2.2)
powerpack (0.1.1)
public_suffix (2.0.4)
puma (3.6.2)
rack (2.0.1)
......@@ -132,12 +136,20 @@ GEM
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rainbow (2.2.1)
rake (12.0.0)
rb-fsevent (0.9.8)
rb-inotify (0.9.7)
ffi (>= 0.5.0)
redcarpet (3.4.0)
redis (3.3.2)
rubocop (0.46.0)
parser (>= 2.3.1.1, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.8.1)
sass (3.4.23)
sass-rails (5.0.6)
railties (>= 4.0.0, < 6)
......@@ -173,6 +185,7 @@ GEM
thread_safe (~> 0.1)
uglifier (3.0.4)
execjs (>= 0.3.0, < 3)
unicode-display_width (1.1.2)
web-console (3.4.0)
actionview (>= 5.0)
activemodel (>= 5.0)
......@@ -205,6 +218,7 @@ DEPENDENCIES
puma (~> 3.0)
rails (~> 5.0.0, >= 5.0.0.1)
redcarpet (~> 3.3, >= 3.3.4)
rubocop (~> 0.46.0)
sass-rails (~> 5.0)
sidekiq (~> 4.2, >= 4.2.7)
spring
......
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
# for example lib/tasks/capistrano.rake,
# and they will automatically be available to Rake.
require_relative 'config/application'
......
module IssueHelper
include ApplicationHelper
def display_time(time)
unless time.nil?
time.strftime('%d/%m/%Y %H:%M:%S')
else
""
end
end
end
......@@ -25,7 +25,7 @@
<td>
<select>
<% value["data"].each do |x| %>
<option><%= x.started_time.to_s + " - " + x.end_time.to_s %></option>
<option><%= display_time(x.started_time) + " - " + display_time(x.end_time) %></option>
<% end %>
</select>
</td>
......
......@@ -12,5 +12,7 @@ module VenturaGhr
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
config.active_job.queue_adapter = :sidekiq
config.time_zone = "Hanoi"
config.active_record.default_timezone = :local # Or :utc
end
end
......@@ -11,7 +11,6 @@ class GithubLoader
last_page = client.last_response.headers[:link].split(' ')[2][-3].to_i
end
# list_db_repo = []
for i in (1..last_page)
repos = client.org_repos($org, {type: 'all', page: i})
repos.each do |repo|
......@@ -29,15 +28,12 @@ class GithubLoader
db_repo.updated_at = repo.updated_at
end
db_repo.save
# list_db_repo.append(db_repo)
end
end
# list_db_repo
end
def insert_labels(client)
$logger.info "Insert labels"
# list_db_label = []
db_repos = Repository.all
db_repos.each do |repo|
labels = client.labels($org + "/" + repo.name)
......@@ -63,11 +59,9 @@ class GithubLoader
db_label.default = label.default
db_label.save
# list_db_label.append(db_label)
end
end
end
# list_db_label
end
def insert_users(client)
......@@ -78,7 +72,6 @@ class GithubLoader
last_page = client.last_response.headers[:link].split(' ')[2][-3].to_i
end
# list_db_user = []
for i in (1..last_page)
users = client.org_members($org, {page: i})
users.each do |user|
......@@ -91,18 +84,14 @@ class GithubLoader
db_user.html_url = user.html_url
end
db_user.save
# list_db_user.append(db_user)
end
end
# list_db_user
end
def insert_issues(client, db_repos)
$logger.info "Insert issues"
list_db_user = User.all
list_db_label = Label.all
# db_repos = Repository.all
# list_db_issue = []
db_repos.each do |repo|
issues = client.list_issues($org + "/" + repo.name, { state: "all" })
......@@ -160,7 +149,7 @@ class GithubLoader
new_timeline(db_issue.id, new_label.name)
end
elsif new_label.name != old_label.name
timeline = Timeline.where(issue_id: db_issue.id, label: old_label.name).first
timeline = Timeline.where(issue_id: db_issue.id, label: old_label.name).last
begin
timeline.end_time = Time.now
timeline.save
......@@ -189,17 +178,13 @@ class GithubLoader
db_issue.save
# list_db_issue.append(db_issue)
end
end
end
# list_db_issue
end
def insert_comments(client, list_db_repo)
$logger.info "Insert comments"
# list_db_comment = []
# list_db_repo = Repository.all
list_db_repo.each do |db_repo|
comments = client.issues_comments($org + "/" + db_repo.name)
......@@ -226,12 +211,9 @@ class GithubLoader
end
db_comment.body = comment.body
db_comment.save
# list_db_comment.append(db_comment)
end
end
end
# $logger.info "Size list_db_comment: " + list_db_comment.size.to_s
# list_db_comment
end
def insert_review_comments(client, list_db_repo)
......@@ -247,7 +229,6 @@ class GithubLoader
rv_comments = client.pull_requests_comments($org + "/" + db_repo.name, { page: i })
rv_comments.each do |rv_comment|
$logger.info rv_comment.body
db_rv_comment = ReviewComment.where(commit_id: rv_comment.commit_id, rv_comment_id: rv_comment.id).first
if db_rv_comment.nil?
db_rv_comment = ReviewComment.new
......@@ -275,7 +256,6 @@ class GithubLoader
db_rv_comment.updated_at = rv_comment.updated_at
db_rv_comment.body = rv_comment.body
db_rv_comment.save
end
end
......
......@@ -16,43 +16,6 @@ namespace :github do
loader.insert_issues($client, Repository.all)
loader.update_issue_pull_association
# $logger.info "begin transaction 1"
# start_time_transaction = Time.now
# ActiveRecord::Base.transaction do
# list_db_repo.each do |db_repo|
# db_repo.save
# end
# list_db_user.each do |db_user|
# db_user.save
# end
# list_db_label.each do |db_label|
# db_label.save
# end
# list_db_issue.each do |db_issue|
# db_issue.save
# end
# end
# $logger.info "Finished transaction1 in #{Time.now - start_time_transaction}s"
# list_db_comment = loader.insert_comments($client, list_db_repo)
# list_db_rv_comment = loader.insert_review_comments($client, list_db_repo)
# start_time_transaction = Time.now
# ActiveRecord::Base.transaction do
# list_db_comment.each do |db_comment|
# db_comment.save
# end
# list_db_rv_comment.each do |db_rv_comment|
# db_rv_comment.save
# end
# end
# $logger.info "Finished transaction2 in #{Time.now - start_time_transaction}s"
$logger.info "Finished task import in #{Time.now - start_time}s"
end
......@@ -67,6 +30,7 @@ namespace :github do
loader.insert_comments($client, list_db_repo)
loader.insert_review_comments($client, list_db_repo)
loader.update_issue_pull_association
$logger.info "Finished task update in #{Time.now - start_time}s"
end
......@@ -98,17 +62,6 @@ namespace :github do
loader.insert_comments($client)
loader.insert_review_comments($client)
# start_time_transaction = Time.now
# ActiveRecord::Base.transaction do
# list_db_comment.each do |db_comment|
# db_comment.save
# end
# list_db_rv_comment.each do |db_rv_comment|
# db_rv_comment.save
# end
# end
# $logger.info "Finished transaction in #{Time.now - start_time_transaction}s"
$logger.info "Finished task import comments in #{Time.now - start_time}s"
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment