Commit 839e5615 by Bui Minh Duc

completed main page

parent fbdb9b04
...@@ -19,7 +19,7 @@ gem 'coffee-rails', '~> 4.2' ...@@ -19,7 +19,7 @@ gem 'coffee-rails', '~> 4.2'
# Use jquery as the JavaScript library # Use jquery as the JavaScript library
gem 'jquery-rails' gem 'jquery-rails'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5' # gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5' gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production # Use Redis adapter to run Action Cable in production
......
...@@ -157,9 +157,6 @@ GEM ...@@ -157,9 +157,6 @@ GEM
thor (0.19.1) thor (0.19.1)
thread_safe (0.3.5) thread_safe (0.3.5)
tilt (2.0.5) tilt (2.0.5)
turbolinks (5.0.1)
turbolinks-source (~> 5)
turbolinks-source (5.0.0)
tzinfo (1.2.2) tzinfo (1.2.2)
thread_safe (~> 0.1) thread_safe (~> 0.1)
uglifier (3.0.3) uglifier (3.0.3)
...@@ -197,7 +194,6 @@ DEPENDENCIES ...@@ -197,7 +194,6 @@ DEPENDENCIES
spring spring
spring-watcher-listen (~> 2.0.0) spring-watcher-listen (~> 2.0.0)
sqlite3 sqlite3
turbolinks (~> 5)
tzinfo-data tzinfo-data
uglifier (>= 1.3.0) uglifier (>= 1.3.0)
web-console web-console
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
// //
//= require jquery //= require jquery
//= require jquery_ujs //= require jquery_ujs
//= require turbolinks
//= require_tree . //= require_tree .
//= require bootstrap-sprockets //= require bootstrap-sprockets
//= require bootstrap-select //= require bootstrap-select
......
class MainController < ApplicationController class MainController < ApplicationController
def index def index
@col_label_names = [
"discussion", "todo", "inprogress",
"vnreview", "jpreview", "ready",
"done", "releasefailed", "pending"]
@label_filter = ["ventura", "priorityurgent", "priorityhigh", "prioritylow"]
@repos = @repos || Repository.all @repos = @repos || Repository.all
@selected_repos_name = Other.where(data_type: 0).map{ |other| other.data } @selected_repos_name = Other.where(data_type: 0).map{ |other| other.data }
@selected_repos = Repository.where(name: @selected_repos_name) @selected_repos = Repository.where(name: @selected_repos_name)
@label_filter = ["ventura", "priority-ugent", "priority-high", "priority-low"]
@col_label_names = [ @label_filter_params = Other.where(data_type: 1).map { |e| e.data }
"discussion", "todo", "inprogress",
"vnreview", "jpreview", "ready",
"done", "releasefailed", "pending", "ventura", "prioritylow", "priorityhigh", "priorityurgent"]
@data_table = [] @data_table = []
@selected_repos.each do |repo| @selected_repos.each do |repo|
...@@ -18,23 +20,27 @@ class MainController < ApplicationController ...@@ -18,23 +20,27 @@ class MainController < ApplicationController
row_table[:link] = repo.html_url row_table[:link] = repo.html_url
row_table[:having_data] = false row_table[:having_data] = false
repo.issues.each do |issue| repo.issues.each do |issue|
issue.labels.each do |label| if session[:filter_date].nil? || session[:filter_date] == "" || Date.parse(issue.created_at.to_s) >= Date.parse(session[:filter_date])
label_name = standardize_string(label[:name]) if @label_filter_params.empty? || filter_issue(issue, @label_filter_params) # filter label condition
@col_label_names.each do |col_label| issue.labels.each do |label|
if label_name == col_label label_name = standardize_string(label[:name])
row_table[:having_data] = true @col_label_names.each do |col_label|
cell = row_table[label_name] || Hash.new if label_name == col_label
if cell[:count].nil? row_table[:having_data] = true
cell[:count] = 1 cell = row_table[label_name] || Hash.new
else if cell[:count].nil?
cell[:count] = cell[:count] + 1 cell[:count] = 1
end else
if cell[:issues].nil? cell[:count] = cell[:count] + 1
cell[:issues] = [] end
if cell[:issues].nil?
cell[:issues] = []
end
cell[:issues].append(issue)
row_table[label_name] = cell
break
end
end end
cell[:issues].append(issue)
row_table[label_name] = cell
break
end end
end end
end end
...@@ -46,19 +52,31 @@ class MainController < ApplicationController ...@@ -46,19 +52,31 @@ class MainController < ApplicationController
end end
def update_repo_selected def update_repo_selected
Other.destroy_all(data_type: 0) Other.where(data_type: 0).delete_all
params[:selected].each do |selected_repo_name| if params[:selected].class == Array
db_selected = Other.new insert_data = []
db_selected.data = selected_repo_name params[:selected].each do |selected_repo_name|
db_selected.data_type = 0 insert_data.append({data: selected_repo_name, data_type: 0})
db_selected.save end
Other.transaction do
Other.create(insert_data)
end
end end
redirect_to action: "index" redirect_to action: "index"
end end
def update_label_selected def update_label_selected
Other.destroy_all(data_type: 1) Other.where(data_type: 1).delete_all
if params[:selected].class == Array
params[:selected].each do |selected_label_name|
db_selected = Other.new
db_selected.data = selected_label_name
db_selected.data_type = 1
db_selected.save
end
end
session[:filter_date] = params[:date]
redirect_to action: "index"
end end
def load_repo_selected def load_repo_selected
...@@ -76,4 +94,22 @@ class MainController < ApplicationController ...@@ -76,4 +94,22 @@ class MainController < ApplicationController
str str
end end
# check if issue have all label in label_filter_params
def filter_issue(issue, label_filter_params)
number = 0
label_filter_params.each do |label_filter_param|
issue.labels.each do |label|
label_name = standardize_string(label[:name])
if label_filter_param == label_name
number = number + 1
break
end
end
end
if number == label_filter_params.size
true
else
false
end
end
end end
...@@ -21,7 +21,8 @@ ...@@ -21,7 +21,8 @@
<!-- content --> <!-- content -->
<div class="form-group"> <div class="form-group">
<label>Select repository</label> <label>Select repository</label>
<select class="selectpicker" id="selectpicker1" multiple data-live-search="true" multiple data-selected-text-format="count > 3"> <select class="selectpicker" id="selectpicker1" multiple data-live-search="true"
multiple data-selected-text-format="count > 3" data-actions-box="true" style="display: none;">
<% @repos.each do |repo| %> <% @repos.each do |repo| %>
<option><%= repo.name %></option> <option><%= repo.name %></option>
<% end %> <% end %>
...@@ -33,21 +34,22 @@ ...@@ -33,21 +34,22 @@
<form class="form-inline"> <form class="form-inline">
<div class="form-group"> <div class="form-group">
<label for="from">From</label> <label for="from">From</label>
<div class='input-group date' id='datetimepicker1'> <div class='input-group date' id='datetimepicker1' data-turbolinks-temporary>
<input type='text' class="form-control" /> <input id="from_date" type='text' class="form-control" value="<%= session[:filter_date] %>" />
<span class="input-group-addon"> <span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span> <span class="glyphicon glyphicon-calendar"></span>
</span> </span>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<select class="selectpicker" multiple data-live-search="true"> <select class="selectpicker" id="selectpicker2" multiple data-live-search="true" style="display: none;">
<% @label_filter.each do |label| %> <% @label_filter.each do |label| %>
<option><%= label %></option> <option><%= label %></option>
<% end %> <% end %>
</select> </select>
</div> </div>
<input type="submit" class="btn btn-default"> <!-- <input type="submit" class="btn btn-default"> -->
<button id="submit_filter" class="btn btn-default">Submit</button>
</form> </form>
</div> </div>
<div style="margin-top: 20px"> <div style="margin-top: 20px">
...@@ -73,12 +75,12 @@ ...@@ -73,12 +75,12 @@
<tbody> <tbody>
<% @data_table.each do |row| %> <% @data_table.each do |row| %>
<tr> <tr>
<td><%= link_to row[:name], row[:link] %></td> <td class="col-md-2"><%= link_to row[:name], row[:link] %></td>
<% @col_label_names.each do |label| %> <% @col_label_names.each do |label| %>
<% if row[label].nil? %> <% if row[label].nil? %>
<td>0</td> <td class="col-md-1">0</td>
<% else %> <% else %>
<td><a href="" data-toggle="modal" data-target="#<%= format_html_id(row[:name] + label) %>"><%= row[label][:count] %></a></td> <td class="col-md-1"><a href="" data-toggle="modal" data-target="#<%= format_html_id(row[:name] + label) %>"><%= row[label][:count] %></a></td>
<% end %> <% end %>
<% end %> <% end %>
...@@ -133,17 +135,7 @@ ...@@ -133,17 +135,7 @@
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {
$('#datetimepicker1').datetimepicker({
format: "DD/MM/YYYY"
});
$('#datetimepicker2').datetimepicker({
format: "DD/MM/YYYY"
});
$('#selectpicker1').selectpicker(); // init picker
$('#selectpicker1').selectpicker('val', <%= @selected_repos_name.to_s.html_safe %>);
$('#selectpicker2').selectpicker(); // init picker
}); });
$("#repo_apply").click(function() { $("#repo_apply").click(function() {
...@@ -154,25 +146,41 @@ ...@@ -154,25 +146,41 @@
url: "<%= update_repo_selected_path %>", url: "<%= update_repo_selected_path %>",
data: { selected: selected_repos }, data: { selected: selected_repos },
success: function(res) { success: function(res) {
// console.log(res);
location.reload(); location.reload();
} }
}); });
}); });
// function load_repos(list_name) { $("#submit_filter").click(function() {
// var result; var selected_labels = $('#selectpicker2').selectpicker('val');
// $.ajax({ var from_date = $("#from_date").val();
// method: "POST",
// url: "<%= load_repo_selected_path %>", $.ajax({
// data: { name: list_name }, method: "POST",
// success: function(res) { url: "<%= update_label_selected_path %>",
// console.log(res); data: { selected: selected_labels, date: from_date },
// result = res; success: function(res) {
// } location.reload();
// }); }
// return result; });
// } });
$(document).on('ready', function(event) {
// location.reload();
$('#datetimepicker1').datetimepicker({
format: "DD/MM/YYYY"
});
$('#datetimepicker2').datetimepicker({
format: "DD/MM/YYYY"
});
$('#selectpicker1').selectpicker(); // init picker
$('#selectpicker1').selectpicker('val', <%= @selected_repos_name.to_s.html_safe %>);
$('#selectpicker2').selectpicker(); // init picker
$('#selectpicker2').selectpicker('val', <%= @label_filter_params.to_s.html_safe %>);
});
</script> </script>
</div> </div>
...@@ -3,6 +3,7 @@ Rails.application.routes.draw do ...@@ -3,6 +3,7 @@ Rails.application.routes.draw do
root "main#index" root "main#index"
get "/repo", to: "repository#index" get "/repo", to: "repository#index"
post "/update_repo_selected", to: "main#update_repo_selected" post "/update_repo_selected", to: "main#update_repo_selected"
post "/update_label_selected", to: "main#update_label_selected"
post "/load_repo_selected", to: "main#load_repo_selected" post "/load_repo_selected", to: "main#load_repo_selected"
# resource :repository # resource :repository
......
# Logfile created on 2016-12-05 10:36:40 +0700 by logger.rb/54362
I, [2016-12-05T10:36:50.133098 #21665] INFO -- : 9.318231148
I, [2016-12-05T10:37:24.881120 #21665] INFO -- : 8.500857799
I, [2016-12-05T10:37:47.821799 #21665] INFO -- : 9.426472738
I, [2016-12-05T10:38:08.779063 #21665] INFO -- : 0.212364933
I, [2016-12-05T10:38:13.244727 #21665] INFO -- : 0.289207592
I, [2016-12-05T10:38:29.144785 #21665] INFO -- : 8.4128716
I, [2016-12-05T10:39:44.032450 #22979] INFO -- : 9.391803434
I, [2016-12-05T10:40:22.663392 #22979] INFO -- : 9.129481358
I, [2016-12-05T10:41:38.326319 #22979] INFO -- : Delete: 9.279934528
I, [2016-12-05T10:41:46.103726 #22979] INFO -- : Delete: 0.000658017
I, [2016-12-05T10:41:54.975597 #22979] INFO -- : All: 8.872523833
I, [2016-12-05T10:44:24.094560 #22979] INFO -- : Delete: 0.134178853
I, [2016-12-05T10:44:24.183602 #22979] INFO -- : All: 0.223217555
I, [2016-12-05T10:44:33.732621 #22979] INFO -- : Delete: 0.092830727
I, [2016-12-05T10:44:42.882490 #22979] INFO -- : All: 9.242711027
I, [2016-12-05T10:44:54.485260 #22979] INFO -- : Delete: 0.110225471
I, [2016-12-05T10:44:54.565676 #22979] INFO -- : All: 0.190640782
I, [2016-12-05T10:48:24.995773 #22979] INFO -- : Delete: 0.081969031
I, [2016-12-05T10:48:33.945115 #22979] INFO -- : All: 9.031292691
I, [2016-12-05T10:48:40.414503 #22979] INFO -- : Delete: 0.25364207
I, [2016-12-05T10:48:40.494559 #22979] INFO -- : All: 0.333697168
I, [2016-12-05T10:48:51.069438 #22979] INFO -- : Delete: 0.066290771
I, [2016-12-05T10:48:59.985578 #22979] INFO -- : All: 8.982432802
I, [2016-12-05T10:49:09.855146 #22979] INFO -- : Delete: 0.124039825
I, [2016-12-05T10:49:09.910064 #22979] INFO -- : All: 0.178955475
I, [2016-12-05T10:50:56.877471 #22979] INFO -- : Delete: 0.272308854
I, [2016-12-05T10:50:57.072826 #22979] INFO -- : All: 0.467666222
I, [2016-12-05T10:51:02.681406 #22979] INFO -- : Delete: 0.112119323
I, [2016-12-05T10:51:08.171061 #22979] INFO -- : Delete: 0.000799749
I, [2016-12-05T10:51:08.244459 #22979] INFO -- : All: 0.07417517
I, [2016-12-05T10:51:11.111547 #22979] INFO -- : Delete: 0.06136411
I, [2016-12-05T10:51:11.288638 #22979] INFO -- : All: 0.238455138
I, [2016-12-05T10:51:20.663314 #22979] INFO -- : Delete: 0.107536246
I, [2016-12-05T10:51:20.727483 #22979] INFO -- : All: 0.171705367
I, [2016-12-05T10:51:24.352531 #22979] INFO -- : Delete: 0.228736534
I, [2016-12-05T10:51:24.529820 #22979] INFO -- : All: 0.406025863
I, [2016-12-05T10:51:46.187297 #22979] INFO -- : Delete: 0.105559013
I, [2016-12-05T10:51:46.259553 #22979] INFO -- : All: 0.177816704
I, [2016-12-05T10:51:49.934840 #22979] INFO -- : Delete: 0.066995402
I, [2016-12-05T10:51:50.103478 #22979] INFO -- : All: 0.235638521
...@@ -38,3 +38,64 @@ I, [2016-12-02T17:03:33.861877 #25408] INFO -- : Insert issues ...@@ -38,3 +38,64 @@ I, [2016-12-02T17:03:33.861877 #25408] INFO -- : Insert issues
I, [2016-12-02T17:07:38.445501 #25408] INFO -- : begin transaction I, [2016-12-02T17:07:38.445501 #25408] INFO -- : begin transaction
I, [2016-12-02T17:07:46.215986 #25408] INFO -- : Finished transaction in 7.770369701s I, [2016-12-02T17:07:46.215986 #25408] INFO -- : Finished transaction in 7.770369701s
I, [2016-12-02T17:07:46.216065 #25408] INFO -- : Finished task import in 462.55293774s I, [2016-12-02T17:07:46.216065 #25408] INFO -- : Finished task import in 462.55293774s
I, [2016-12-05T09:00:03.275961 #15540] INFO -- : Begin task insert database from github
I, [2016-12-05T09:00:03.276121 #15540] INFO -- : Insert repos
I, [2016-12-05T09:00:08.893967 #15540] INFO -- : Insert users
I, [2016-12-05T09:00:14.415520 #15540] INFO -- : Insert labels
I, [2016-12-05T09:03:34.682845 #15540] INFO -- : Insert issues
I, [2016-12-05T09:07:32.412639 #15540] INFO -- : begin transaction
I, [2016-12-05T09:07:41.812828 #15540] INFO -- : Finished transaction in 9.400057373s
I, [2016-12-05T09:07:41.812907 #15540] INFO -- : Finished task import in 458.536787111s
I, [2016-12-05T10:00:03.379950 #19348] INFO -- : Begin task insert database from github
I, [2016-12-05T10:00:03.380036 #19348] INFO -- : Insert repos
I, [2016-12-05T10:00:12.380606 #19348] INFO -- : Insert users
I, [2016-12-05T10:00:19.151197 #19348] INFO -- : Insert labels
I, [2016-12-05T10:05:34.906828 #19348] INFO -- : Insert issues
I, [2016-12-05T10:09:40.184169 #19348] INFO -- : begin transaction
I, [2016-12-05T10:09:49.104566 #19348] INFO -- : Finished transaction in 8.920291947s
I, [2016-12-05T10:09:49.104651 #19348] INFO -- : Finished task import in 585.724609527s
I, [2016-12-05T11:00:02.673673 #24314] INFO -- : Begin task insert database from github
I, [2016-12-05T11:00:02.673783 #24314] INFO -- : Insert repos
I, [2016-12-05T11:00:08.352538 #24314] INFO -- : Insert users
I, [2016-12-05T11:00:14.122472 #24314] INFO -- : Insert labels
I, [2016-12-05T11:03:32.154641 #24314] INFO -- : Insert issues
I, [2016-12-05T11:07:29.619055 #24314] INFO -- : begin transaction
I, [2016-12-05T11:07:35.151931 #24314] INFO -- : Finished transaction in 5.532775647s
I, [2016-12-05T11:07:35.152047 #24314] INFO -- : Finished task import in 452.478254936s
I, [2016-12-05T11:32:52.814642 #27105] INFO -- : Begin task insert database from github
I, [2016-12-05T11:32:52.814734 #27105] INFO -- : Insert repos
I, [2016-12-05T11:32:57.997112 #27105] INFO -- : Insert users
I, [2016-12-05T11:33:03.864780 #27105] INFO -- : Insert labels
I, [2016-12-05T11:36:23.651270 #27105] INFO -- : Insert issues
I, [2016-12-05T11:40:25.656131 #27105] INFO -- : begin transaction
I, [2016-12-05T11:40:30.670793 #27105] INFO -- : Finished transaction in 5.014476519s
I, [2016-12-05T11:40:30.670845 #27105] INFO -- : Finished task import in 457.856110823s
I, [2016-12-05T12:00:02.724115 #27838] INFO -- : Begin task insert database from github
I, [2016-12-05T12:00:02.724218 #27838] INFO -- : Insert repos
I, [2016-12-05T12:00:08.556158 #27838] INFO -- : Insert users
I, [2016-12-05T12:00:14.195700 #27838] INFO -- : Insert labels
I, [2016-12-05T12:03:34.050850 #27838] INFO -- : Insert issues
I, [2016-12-05T12:07:34.413718 #27838] INFO -- : begin transaction
I, [2016-12-05T12:07:39.623579 #27838] INFO -- : Finished transaction in 5.209779346s
I, [2016-12-05T12:07:39.623630 #27838] INFO -- : Finished task import in 456.899410722s
I, [2016-12-05T12:35:43.765832 #28960] INFO -- : Begin task insert database from github
I, [2016-12-05T12:35:43.765918 #28960] INFO -- : Insert repos
I, [2016-12-05T12:35:48.927996 #28960] INFO -- : Insert users
I, [2016-12-05T12:35:54.421529 #28960] INFO -- : Insert labels
I, [2016-12-05T12:39:12.370543 #28960] INFO -- : Insert issues
I, [2016-12-05T12:43:11.201248 #28960] INFO -- : begin transaction
I, [2016-12-05T12:43:17.583190 #28960] INFO -- : Finished transaction in 6.381851532s
I, [2016-12-05T12:43:17.583267 #28960] INFO -- : Finished task import in 453.817346896s
I, [2016-12-05T13:00:03.230271 #30452] INFO -- : Begin task insert database from github
I, [2016-12-05T13:00:03.230379 #30452] INFO -- : Insert repos
I, [2016-12-05T13:00:08.468859 #30452] INFO -- : Insert users
I, [2016-12-05T13:00:14.221795 #30452] INFO -- : Insert labels
I, [2016-12-05T13:03:32.162037 #30452] INFO -- : Insert issues
I, [2016-12-05T13:07:30.487134 #30452] INFO -- : begin transaction
I, [2016-12-05T13:07:39.075745 #30452] INFO -- : Finished transaction in 8.588511138s
I, [2016-12-05T13:07:39.075873 #30452] INFO -- : Finished task import in 455.845489034s
I, [2016-12-05T14:00:02.715508 #3731] INFO -- : Begin task insert database from github
I, [2016-12-05T14:00:02.715604 #3731] INFO -- : Insert repos
I, [2016-12-05T14:00:08.486465 #3731] INFO -- : Insert users
I, [2016-12-05T14:00:14.200676 #3731] INFO -- : Insert labels
I, [2016-12-05T14:03:32.452579 #3731] INFO -- : Insert issues
...@@ -22,21 +22,22 @@ namespace :github do ...@@ -22,21 +22,22 @@ namespace :github do
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
Repository.destroy_all Repository.destroy_all
User.destroy_all
Label.destroy_all
Issue.destroy_all
list_db_repo.each do |db_repo| list_db_repo.each do |db_repo|
db_repo.save db_repo.save
end end
User.destroy_all
list_db_user.each do |db_user| list_db_user.each do |db_user|
db_user.save db_user.save
end end
Label.destroy_all
list_db_label.each do |db_label| list_db_label.each do |db_label|
db_label.save db_label.save
end end
Issue.destroy_all
list_db_issue.each do |db_issue| list_db_issue.each do |db_issue|
db_issue.save db_issue.save
end 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