Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
much faster branch graphs for the dashboard
- Loading branch information
svs
committed
Jun 1, 2009
1 parent
445c8db
commit e188168
Showing
22 changed files
with
712 additions
and
9 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 |
---|---|---|
|
@@ -20,3 +20,4 @@ gems/gems/* | |
gems/specifications/* | ||
merb_profile_results | ||
misfit_fixtures/* | ||
config/database.yml |
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,12 @@ | ||
class Search < Application | ||
|
||
def index | ||
debugger | ||
model = Kernel.const_get(params[:model]) | ||
parameter = params[:by].snake_case.to_sym | ||
@object = model.all( parameter => params[:value])[0] | ||
raise NotFound unless @object | ||
redirect "/#{model.to_s.snake_case.pluralize}/#{@object.id}" | ||
end | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module Merb | ||
module SearchHelper | ||
|
||
end | ||
end # Merb |
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,36 @@ | ||
93235-55017 sandeep | ||
class Client | ||
include DataMapper::Resource | ||
include Paperclip::Resource | ||
before :valid?, :parse_dates | ||
|
||
property :id, Serial | ||
property :reference, String, :length => 100, :nullable => false | ||
property :name, String, :length => 100, :nullable => false | ||
property :spouse_name, String, :length => 100 | ||
property :date_of_birth, Date | ||
property :address, Text | ||
property :active, Boolean, :default => true, :nullable => false | ||
property :date_joined, Date | ||
|
||
has_attached_file :picture, | ||
:styles => {:medium => "300x300>", :thumb => "60x60#"}, | ||
:url => "/uploads/:class/:id/:attachment/:style/:basename.:extension", | ||
:path => "#{Merb.root}/public/uploads/:class/:id/:attachment/:style/:basename.:extension" | ||
|
||
has_attached_file :application_form, | ||
:styles => {:medium => "300x300>", :thumb => "60x60#"}, | ||
:url => "/uploads/:class/:id/:attachment/:style/:basename.:extension", | ||
:path => "#{Merb.root}/public/uploads/:class/:id/:attachment/:style/:basename.:extension" | ||
|
||
has n, :loans | ||
belongs_to :center | ||
|
||
validates_length :name, :min => 3 | ||
validates_present :center | ||
validates_is_unique :reference | ||
|
||
|
||
private | ||
include DateParser # mixin for the hook "before :valid?, :parse_dates" | ||
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
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,2 @@ | ||
%status | ||
= @payment.status |
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,15 @@ | ||
%h1 | ||
Reports | ||
|
||
%table#mytable{:width => "100%"} | ||
%tr | ||
- @reports.each do |report| | ||
%tr | ||
%td | ||
= report.name | ||
%td | ||
= link_to 'Show', url(:report, report) | ||
%td | ||
= link_to 'Edit', url(:edit_report, report) | ||
|
||
= link_to 'New', url(:new_report) |
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,104 @@ | ||
%h2 | ||
= @report.name | ||
|
||
- @branch_loans = {} | ||
- Branch.all.each do |branch| | ||
- @branch_loans[branch.id] = Loan.all('client.center.branch_id' => branch.id) | ||
|
||
%table | ||
%tr | ||
%th | ||
Parameter | ||
%th | ||
All Branches | ||
- Branch.all.each do |branch| | ||
%th | ||
= branch.name | ||
%tr | ||
%th | ||
No. of CM | ||
%td | ||
= Center.all.manager.uniq.count | ||
- Branch.all.each do |branch| | ||
%td | ||
= Center.all(:branch_id => branch.id).manager.uniq.count | ||
%tr | ||
%th | ||
No. of Centers | ||
%td | ||
= Center.all.count | ||
- Branch.all.each do |branch| | ||
%td | ||
= Center.all(:branch_id => branch.id).count | ||
%tr | ||
%th | ||
No. of Clients | ||
%td | ||
= Client.all.count | ||
- Branch.all.each do |branch| | ||
%td | ||
= Client.all('center.branch_id' => branch.id).count | ||
%tr | ||
%th | ||
No. of Clients | ||
%td | ||
= Client.all.count | ||
- Branch.all.each do |branch| | ||
%td | ||
= Client.all('center.branch_id' => branch.id).count | ||
%tr | ||
%th | ||
No. of Borowers | ||
%td | ||
= repository(:default).adapter.query("SELECT COUNT(DISTINCT(client_id)) FROM loans")[0] | ||
- Branch.all.each do |branch| | ||
%td | ||
= repository.adapter.query("SELECT COUNT(DISTINCT(client_id)) FROM loans,clients,centers,branches WHERE loans.client_id = clients.id AND clients.center_id = centers.id AND centers.branch_id = branches.id AND branches.id = #{branch.id}")[0] | ||
%tr | ||
%th | ||
Loans for next week (number) | ||
%td | ||
= Loan.all(:scheduled_disbursal_date.gt => Date.today, :scheduled_disbursal_date.lt => Date.today + 7).count | ||
- Branch.all.each do |branch| | ||
%td | ||
= @branch_loans[branch.id].all(:scheduled_disbursal_date.gt => Date.today, :scheduled_disbursal_date.lt => (Date.today + 7)).count | ||
%tr | ||
%th | ||
Loans for next week (amount) | ||
%td | ||
= Loan.all(:scheduled_disbursal_date.gt => Date.today, :scheduled_disbursal_date.lt => Date.today + 7).sum(:amount) || 0 | ||
- Branch.all.each do |branch| | ||
%td | ||
= @branch_loans[branch.id].all(:scheduled_disbursal_date.gt => Date.today, :scheduled_disbursal_date.lt => (Date.today + 7)).sum(:amount) || 0 | ||
%tr | ||
%th | ||
Waiting Clients (number) | ||
%td | ||
= Loan.all(:scheduled_disbursal_date.not => nil, :disbursal_date => nil).count | ||
- Branch.all.each do |branch| | ||
%td | ||
= @branch_loans[branch.id].all(:scheduled_disbursal_date.not => nil, :disbursal_date => nil, 'client.center.branch_id' => branch.id).count | ||
%tr | ||
%th | ||
Waiting Clients (amount) | ||
%td | ||
= Loan.all(:scheduled_disbursal_date.not => nil, :disbursal_date => nil).sum(:amount) | ||
- Branch.all.each do |branch| | ||
%td | ||
= @branch_loans[branch.id].all(:scheduled_disbursal_date.not => nil, :disbursal_date => nil, 'client.center.branch_id' => branch.id).sum(:amount) | ||
%tr | ||
%th | ||
Defaulted Loans (Count) | ||
%td | ||
= LoanHistory.all(:current => true, :amount_in_default.not => 0).count | ||
- Branch.all.each do |branch| | ||
%td | ||
= LoanHistory.all(:current => true, :amount_in_default.not => 0, 'loan.client.center.branch_id' => branch.id).count | ||
%tr | ||
%th | ||
Defaulted Loans (Amount) | ||
%td | ||
= LoanHistory.all(:current => true, :amount_in_default.not => 0).sum(:amount_in_default) | ||
- Branch.all.each do |branch| | ||
%td | ||
= LoanHistory.all(:current => true, :amount_in_default.not => 0, 'loan.client.center.branch_id' => branch.id).sum(:amount_in_default) |
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 @@ | ||
You're in index of the Search controller. |
Oops, something went wrong.