-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add audit functionality to the application
- Loading branch information
Showing
9 changed files
with
163 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,25 @@ | ||
class AuditController < ApplicationController | ||
def index | ||
@collectives = Collective.where(projects_count: 0).where('balance > 0').order(balance: :desc).select{|c| c.project_url.present?} | ||
redirect_to action: :user_owners | ||
end | ||
|
||
def user_owners | ||
@collectives = Collective.with_user_owner.with_transactions.order(transactions_count: :desc) | ||
end | ||
|
||
@archived = Collective.where(projects_count: 1).select{|c| c.projects.first && c.projects.first.repository && c.projects.first.repository['archived']} | ||
def no_projects | ||
@collectives = Collective.where(projects_count: 0).with_transactions.order(transactions_count: :desc).select{|c| c.project_url.present?} | ||
end | ||
|
||
def no_license | ||
@collectives = Collective.where(projects_count: 1).select{|c| c.projects.first && c.projects.first.repository && !c.projects.first.repository['archived'] && c.projects.first.repository['license'].blank?} | ||
end | ||
|
||
@no_license = Collective.where(projects_count: 1).select{|c| c.projects.first && c.projects.first.repository && !c.projects.first.repository['archived'] && c.projects.first.repository['license'].blank?} | ||
def archived | ||
@collectives = Collective.where(projects_count: 1).select{|c| c.projects.first && c.projects.first.repository && c.projects.first.repository['archived']} | ||
end | ||
|
||
# collectives where owner is a user instead of an org | ||
# collectives with invalid urls | ||
# collectives with no projects | ||
# collectives with inactive projects | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<ul class="nav nav-tabs my-3"> | ||
<li class="nav-item"> | ||
<a class="nav-link <%= 'active' if params[:action] == 'user_owners' %>" href='/audit/user_owners'>User owners</a> | ||
</li> | ||
<li class="nav-item"> | ||
<a class="nav-link <%= 'active' if params[:action] == 'no_projects' %>" href='/audit/no_projects'>No projects</a> | ||
</li> | ||
<li class="nav-item"> | ||
<a class="nav-link <%= 'active' if params[:action] == 'no_license' %>" href='/audit/no_license'>No license</a> | ||
</li> | ||
<li class="nav-item"> | ||
<a class="nav-link <%= 'active' if params[:action] == 'archived' %>" href='/audit/archived'>Archived</a> | ||
</li> | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<div class="container-md"> | ||
<h2>Audit</h2> | ||
|
||
<%= render 'nav' %> | ||
|
||
<% @collectives.each do |collective| %> | ||
<div class="collective card my-2"> | ||
<div class='card-body'> | ||
<div class="d-flex"> | ||
|
||
<div class="flex-grow-1 ms-3 text-break"> | ||
<h4><%= link_to collective.name, collective %></h4> | ||
<p><%= collective.description %></p> | ||
<p><%= number_with_delimiter collective.projects_count %> repository - <%= number_with_delimiter collective.transactions_count %> transactions - Balance: <%= collective.balance.round(2)%> <%= collective.currency %></p> | ||
<p>Project url: <%= link_to collective.project_url, collective.project_url, target: :_blank %></p> | ||
</div> | ||
<div class="flex-shrink-0"> | ||
<img src="<%= collective.icon_url %>" class="rounded" height='40' width='40' onerror="this.style.display='none'"> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<% end %> | ||
|
||
<p> | ||
<i> | ||
<small> | ||
Displaying <%= pluralize @collectives.length, 'collective' %> with exactly 1 repository, that has been archived. | ||
</small> | ||
</i> | ||
</p> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +0,0 @@ | ||
<div class="container-md"> | ||
<h2>Audit</h2> | ||
<ul> | ||
<li><a href='#no-projects'>No projects</a></li> | ||
<li><a href='#no-license'>No license</a></li> | ||
<li><a href='#archived'>Archived repo</a></li> | ||
</ul> | ||
|
||
<h3 id='no-projects'>Collectives with no projects</h3> | ||
|
||
<% @collectives.each do |collective| %> | ||
<div class="collective card my-2"> | ||
<div class='card-body'> | ||
<h4><%= link_to collective.name, collective %></h4> | ||
<p><%= collective.description %></p> | ||
<p><%= link_to collective.project_url, collective.project_url, target: :_blank %></p> | ||
</div> | ||
</div> | ||
<% end %> | ||
|
||
<hr> | ||
|
||
<h3 id='no-license'>Collectives with no license</h3> | ||
|
||
<% @no_license.each do |collective| %> | ||
<div class="collective card my-2"> | ||
<div class='card-body'> | ||
<h4><%= link_to collective.name, collective %></h4> | ||
<p><%= link_to collective.projects.first.repository_url, collective.projects.first.repository_url, target: :_blank %></p> | ||
</div> | ||
</div> | ||
<% end %> | ||
|
||
<hr> | ||
|
||
<h3 id='archived'>Collectives with archived repo</h3> | ||
|
||
<% @archived.each do |collective| %> | ||
<div class="collective card my-2"> | ||
<div class='card-body'> | ||
<h4><%= link_to collective.name, collective %></h4> | ||
<p><%= link_to collective.projects.first.repository_url, collective.projects.first.repository_url, target: :_blank %></p> | ||
</div> | ||
</div> | ||
<% end %> | ||
</div> | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<div class="container-md"> | ||
<h2>Audit</h2> | ||
|
||
<%= render 'nav' %> | ||
|
||
<% @collectives.each do |collective| %> | ||
<div class="collective card my-2"> | ||
<div class='card-body'> | ||
<div class="d-flex"> | ||
|
||
<div class="flex-grow-1 ms-3 text-break"> | ||
<h4><%= link_to collective.name, collective %></h4> | ||
<p><%= collective.description %></p> | ||
<p><%= number_with_delimiter collective.projects_count %> repository - <%= number_with_delimiter collective.transactions_count %> transactions - Balance: <%= collective.balance.round(2)%> <%= collective.currency %></p> | ||
<p>Project url: <%= link_to collective.project_url, collective.project_url, target: :_blank %></p> | ||
</div> | ||
<div class="flex-shrink-0"> | ||
<img src="<%= collective.icon_url %>" class="rounded" height='40' width='40' onerror="this.style.display='none'"> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<% end %> | ||
|
||
<p> | ||
<i> | ||
<small> | ||
Displaying <%= pluralize @collectives.length, 'collective' %> with exactly 1 repository, that we can't detect a license for. | ||
</small> | ||
</i> | ||
</p> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<div class="container-md"> | ||
<h2>Audit</h2> | ||
|
||
<%= render 'nav' %> | ||
|
||
<% @collectives.each do |collective| %> | ||
<div class="collective card my-2"> | ||
<div class='card-body'> | ||
<div class="d-flex"> | ||
|
||
<div class="flex-grow-1 ms-3 text-break"> | ||
<h4><%= link_to collective.name, collective %></h4> | ||
<p><%= collective.description %></p> | ||
<p><%= number_with_delimiter collective.projects_count %> repositories - <%= number_with_delimiter collective.transactions_count %> transactions - Balance: <%= collective.balance.round(2)%> <%= collective.currency %></p> | ||
<p>Project url: <%= link_to collective.project_url, collective.project_url, target: :_blank %></p> | ||
</div> | ||
<div class="flex-shrink-0"> | ||
<img src="<%= collective.icon_url %>" class="rounded" height='40' width='40' onerror="this.style.display='none'"> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<% end %> | ||
|
||
<p> | ||
<i> | ||
<small> | ||
Displaying <%= pluralize @collectives.length, 'collective' %>, excluding collectives with no transactions, that we found a project url for, but couldn't load any projects from. | ||
</small> | ||
</i> | ||
</p> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<div class="container-md"> | ||
<h2>Audit</h2> | ||
|
||
<%= render 'nav' %> | ||
|
||
<% @collectives.each do |collective| %> | ||
<div class="collective card my-2"> | ||
<div class='card-body'> | ||
<div class="d-flex"> | ||
|
||
<div class="flex-grow-1 ms-3 text-break"> | ||
<h4><%= link_to collective.name, collective %></h4> | ||
<p><%= collective.description %></p> | ||
<p><%= number_with_delimiter collective.projects_count %> repositories - <%= number_with_delimiter collective.transactions_count %> transactions - Balance: <%= collective.balance.round(2)%> <%= collective.currency %></p> | ||
<p>Owner: <%= link_to collective.owner['login'], collective.owner['html_url'], target: :_blank %></p> | ||
</div> | ||
<div class="flex-shrink-0"> | ||
<img src="<%= collective.icon_url %>" class="rounded" height='40' width='40' onerror="this.style.display='none'"> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<% end %> | ||
|
||
<p> | ||
<i> | ||
<small> | ||
Displaying <%= pluralize @collectives.length, 'collective' %>, excluding collectives with no transactions, owned by a user instead of an organization. | ||
</small> | ||
</i> | ||
</p> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters