From d848831feac18618b14a2ceed95bd99dfa10fa49 Mon Sep 17 00:00:00 2001 From: Benjamin Meichsner Date: Sat, 1 Aug 2009 13:41:22 +0200 Subject: [PATCH] Implemented stats for ordergroups on startpage. Annotated models. --- app/models/article.rb | 17 ++++---- app/models/article_category.rb | 3 +- app/models/article_price.rb | 7 ++-- app/models/assignment.rb | 9 ++-- app/models/delivery.rb | 5 +-- app/models/financial_transaction.rb | 9 ++-- app/models/group.rb | 22 +++++----- app/models/group_order.rb | 11 +++-- app/models/group_order_article.rb | 13 +++--- app/models/group_order_article_quantity.rb | 9 ++-- app/models/invite.rb | 7 ++-- app/models/invoice.rb | 13 +++--- app/models/membership.rb | 7 ++-- app/models/message.rb | 9 ++-- app/models/order.rb | 13 +++--- app/models/order_article.rb | 17 ++++---- app/models/order_comment.rb | 7 ++-- app/models/ordergroup.rb | 42 ++++++++++++++----- app/models/stock_article.rb | 17 ++++---- app/models/stock_change.rb | 13 +++--- app/models/stock_taking.rb | 3 +- app/models/supplier.rb | 5 +-- app/models/task.rb | 22 ++++++---- app/models/user.rb | 3 +- app/models/workgroup.rb | 22 +++++----- app/views/home/_stats.erb | 24 +++++++++++ app/views/home/index.html.haml | 12 ++++-- .../20090731132547_add_stats_to_groups.rb | 11 +++++ db/schema.rb | 3 +- public/stylesheets/main.css | 29 +++++++++---- public/stylesheets/print.css | 29 +++++++++---- public/stylesheets/sass/main.sass | 18 +++++++- test/fixtures/article_categories.yml | 3 +- test/fixtures/article_prices.yml | 7 ++-- test/fixtures/articles.yml | 17 ++++---- test/fixtures/assignments.yml | 9 ++-- test/fixtures/financial_transactions.yml | 9 ++-- .../group_order_article_quantities.yml | 9 ++-- test/fixtures/groups.yml | 22 +++++----- test/fixtures/memberships.yml | 7 ++-- test/fixtures/messages.yml | 9 ++-- test/fixtures/order_comments.yml | 7 ++-- test/fixtures/orders.yml | 9 ++-- test/fixtures/stock_changes.yml | 13 +++--- test/fixtures/stock_takings.yml | 3 +- test/fixtures/suppliers.yml | 1 - test/fixtures/tasks.yml | 13 +++--- test/fixtures/users.yml | 3 +- test/unit/article_category_test.rb | 3 +- test/unit/article_price_test.rb | 7 ++-- test/unit/article_test.rb | 17 ++++---- test/unit/assignment_test.rb | 9 ++-- test/unit/financial_transaction_test.rb | 9 ++-- .../unit/group_order_article_quantity_test.rb | 9 ++-- test/unit/group_test.rb | 22 +++++----- test/unit/membership_test.rb | 7 ++-- test/unit/order_comment_test.rb | 7 ++-- test/unit/order_test.rb | 9 ++-- test/unit/stock_article_test.rb | 17 ++++---- test/unit/stock_change_test.rb | 13 +++--- test/unit/stock_taking_test.rb | 3 +- test/unit/supplier_test.rb | 5 +-- test/unit/task_test.rb | 11 +++-- test/unit/user_test.rb | 3 +- test/unit/workgroup_test.rb | 22 +++++----- 65 files changed, 407 insertions(+), 338 deletions(-) create mode 100644 app/views/home/_stats.erb create mode 100644 db/migrate/20090731132547_add_stats_to_groups.rb diff --git a/app/models/article.rb b/app/models/article.rb index 92fb1f86..de224304 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -1,28 +1,27 @@ # == Schema Information -# Schema version: 20090120184410 # # Table name: articles # -# id :integer not null, primary key +# id :integer(4) not null, primary key # name :string(255) default(""), not null -# supplier_id :integer default(0), not null -# article_category_id :integer default(0), not null +# supplier_id :integer(4) default(0), not null +# article_category_id :integer(4) default(0), not null # unit :string(255) default(""), not null # note :string(255) -# availability :boolean default(TRUE), not null +# availability :boolean(1) default(TRUE), not null # manufacturer :string(255) # origin :string(255) # shared_updated_on :datetime -# price :decimal(, ) +# price :decimal(8, 2) # tax :float -# deposit :decimal(, ) default(0.0) -# unit_quantity :integer default(1), not null +# deposit :decimal(8, 2) default(0.0) +# unit_quantity :integer(4) default(1), not null # order_number :string(255) # created_at :datetime # updated_at :datetime -# quantity :integer default(0) # deleted_at :datetime # type :string(255) +# quantity :integer(4) default(0) # class Article < ActiveRecord::Base diff --git a/app/models/article_category.rb b/app/models/article_category.rb index d61ee3be..57a87dbb 100644 --- a/app/models/article_category.rb +++ b/app/models/article_category.rb @@ -1,9 +1,8 @@ # == Schema Information -# Schema version: 20090119155930 # # Table name: article_categories # -# id :integer not null, primary key +# id :integer(4) not null, primary key # name :string(255) default(""), not null # description :string(255) # diff --git a/app/models/article_price.rb b/app/models/article_price.rb index 1a63a456..e0926d4a 100644 --- a/app/models/article_price.rb +++ b/app/models/article_price.rb @@ -1,14 +1,13 @@ # == Schema Information -# Schema version: 20090119155930 # # Table name: article_prices # -# id :integer not null, primary key -# article_id :integer +# id :integer(4) not null, primary key +# article_id :integer(4) # price :decimal(8, 2) default(0.0), not null # tax :decimal(8, 2) default(0.0), not null # deposit :decimal(8, 2) default(0.0), not null -# unit_quantity :integer +# unit_quantity :integer(4) # created_at :datetime # diff --git a/app/models/assignment.rb b/app/models/assignment.rb index b5113f49..e5f21c39 100644 --- a/app/models/assignment.rb +++ b/app/models/assignment.rb @@ -1,12 +1,11 @@ # == Schema Information -# Schema version: 20090119155930 # # Table name: assignments # -# id :integer not null, primary key -# user_id :integer default(0), not null -# task_id :integer default(0), not null -# accepted :boolean +# id :integer(4) not null, primary key +# user_id :integer(4) default(0), not null +# task_id :integer(4) default(0), not null +# accepted :boolean(1) # class Assignment < ActiveRecord::Base diff --git a/app/models/delivery.rb b/app/models/delivery.rb index c54e9df3..db04e7ad 100644 --- a/app/models/delivery.rb +++ b/app/models/delivery.rb @@ -1,10 +1,9 @@ # == Schema Information -# Schema version: 20090119155930 # # Table name: deliveries # -# id :integer not null, primary key -# supplier_id :integer +# id :integer(4) not null, primary key +# supplier_id :integer(4) # delivered_on :date # created_at :datetime # diff --git a/app/models/financial_transaction.rb b/app/models/financial_transaction.rb index 12acd177..731c5f42 100644 --- a/app/models/financial_transaction.rb +++ b/app/models/financial_transaction.rb @@ -1,13 +1,12 @@ # == Schema Information -# Schema version: 20090119155930 # # Table name: financial_transactions # -# id :integer not null, primary key -# ordergroup_id :integer default(0), not null +# id :integer(4) not null, primary key +# ordergroup_id :integer(4) default(0), not null # amount :decimal(8, 2) default(0.0), not null -# note :text not null -# user_id :integer default(0), not null +# note :text default(""), not null +# user_id :integer(4) default(0), not null # created_on :datetime not null # diff --git a/app/models/group.rb b/app/models/group.rb index 7a25c313..53e835d2 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -1,29 +1,29 @@ # == Schema Information -# Schema version: 20090120184410 # # Table name: groups # -# id :integer not null, primary key +# id :integer(4) not null, primary key # type :string(255) default(""), not null # name :string(255) default(""), not null # description :string(255) -# account_balance :decimal(, ) default(0.0), not null +# account_balance :decimal(8, 2) default(0.0), not null # account_updated :datetime # created_on :datetime not null -# role_admin :boolean not null -# role_suppliers :boolean not null -# role_article_meta :boolean not null -# role_finance :boolean not null -# role_orders :boolean not null -# weekly_task :boolean -# weekday :integer +# role_admin :boolean(1) not null +# role_suppliers :boolean(1) not null +# role_article_meta :boolean(1) not null +# role_finance :boolean(1) not null +# role_orders :boolean(1) not null +# weekly_task :boolean(1) +# weekday :integer(4) # task_name :string(255) # task_description :string(255) -# task_required_users :integer default(1) +# task_required_users :integer(4) default(1) # deleted_at :datetime # contact_person :string(255) # contact_phone :string(255) # contact_address :string(255) +# stats :text # # Groups organize the User. diff --git a/app/models/group_order.rb b/app/models/group_order.rb index d4ca7c69..1a730b88 100644 --- a/app/models/group_order.rb +++ b/app/models/group_order.rb @@ -1,15 +1,14 @@ # == Schema Information -# Schema version: 20090119155930 # # Table name: group_orders # -# id :integer not null, primary key -# ordergroup_id :integer default(0), not null -# order_id :integer default(0), not null +# id :integer(4) not null, primary key +# ordergroup_id :integer(4) default(0), not null +# order_id :integer(4) default(0), not null # price :decimal(8, 2) default(0.0), not null -# lock_version :integer default(0), not null +# lock_version :integer(4) default(0), not null # updated_on :datetime not null -# updated_by_user_id :integer +# updated_by_user_id :integer(4) # # A GroupOrder represents an Order placed by an Ordergroup. diff --git a/app/models/group_order_article.rb b/app/models/group_order_article.rb index 0b486c90..f5c0c223 100644 --- a/app/models/group_order_article.rb +++ b/app/models/group_order_article.rb @@ -1,15 +1,14 @@ # == Schema Information -# Schema version: 20090120184410 # # Table name: group_order_articles # -# id :integer not null, primary key -# group_order_id :integer default(0), not null -# order_article_id :integer default(0), not null -# quantity :integer default(0), not null -# tolerance :integer default(0), not null +# id :integer(4) not null, primary key +# group_order_id :integer(4) default(0), not null +# order_article_id :integer(4) default(0), not null +# quantity :integer(4) default(0), not null +# tolerance :integer(4) default(0), not null # updated_on :datetime not null -# result :integer +# result :decimal(8, 3) # # A GroupOrderArticle stores the sum of how many items of an OrderArticle are ordered as part of a GroupOrder. diff --git a/app/models/group_order_article_quantity.rb b/app/models/group_order_article_quantity.rb index 53bbcca4..fdb5e7b3 100644 --- a/app/models/group_order_article_quantity.rb +++ b/app/models/group_order_article_quantity.rb @@ -1,12 +1,11 @@ # == Schema Information -# Schema version: 20090119155930 # # Table name: group_order_article_quantities # -# id :integer not null, primary key -# group_order_article_id :integer default(0), not null -# quantity :integer default(0) -# tolerance :integer default(0) +# id :integer(4) not null, primary key +# group_order_article_id :integer(4) default(0), not null +# quantity :integer(4) default(0) +# tolerance :integer(4) default(0) # created_on :datetime not null # diff --git a/app/models/invite.rb b/app/models/invite.rb index 588dfeb7..9ae84950 100644 --- a/app/models/invite.rb +++ b/app/models/invite.rb @@ -1,13 +1,12 @@ # == Schema Information -# Schema version: 20090119155930 # # Table name: invites # -# id :integer not null, primary key +# id :integer(4) not null, primary key # token :string(255) default(""), not null # expires_at :datetime not null -# group_id :integer default(0), not null -# user_id :integer default(0), not null +# group_id :integer(4) default(0), not null +# user_id :integer(4) default(0), not null # email :string(255) default(""), not null # diff --git a/app/models/invoice.rb b/app/models/invoice.rb index 05c69dab..aed79d95 100644 --- a/app/models/invoice.rb +++ b/app/models/invoice.rb @@ -1,21 +1,20 @@ # == Schema Information -# Schema version: 20090119155930 # # Table name: invoices # -# id :integer not null, primary key -# supplier_id :integer -# delivery_id :integer +# id :integer(4) not null, primary key +# supplier_id :integer(4) +# delivery_id :integer(4) +# order_id :integer(4) # number :string(255) # date :date # paid_on :date # note :text # amount :decimal(8, 2) default(0.0), not null -# created_at :datetime -# updated_at :datetime -# order_id :integer # deposit :decimal(8, 2) default(0.0), not null # deposit_credit :decimal(8, 2) default(0.0), not null +# created_at :datetime +# updated_at :datetime # class Invoice < ActiveRecord::Base diff --git a/app/models/membership.rb b/app/models/membership.rb index 343ced61..bf847404 100644 --- a/app/models/membership.rb +++ b/app/models/membership.rb @@ -1,11 +1,10 @@ # == Schema Information -# Schema version: 20090119155930 # # Table name: memberships # -# id :integer not null, primary key -# group_id :integer default(0), not null -# user_id :integer default(0), not null +# id :integer(4) not null, primary key +# group_id :integer(4) default(0), not null +# user_id :integer(4) default(0), not null # class Membership < ActiveRecord::Base diff --git a/app/models/message.rb b/app/models/message.rb index 8fd1fb62..9853f9ee 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -1,15 +1,14 @@ # == Schema Information -# Schema version: 20090119155930 # # Table name: messages # -# id :integer not null, primary key -# sender_id :integer +# id :integer(4) not null, primary key +# sender_id :integer(4) # recipients_ids :text # subject :string(255) not null # body :text -# email_state :integer default(0), not null -# private :boolean +# email_state :integer(4) default(0), not null +# private :boolean(1) # created_at :datetime # diff --git a/app/models/order.rb b/app/models/order.rb index 03ae8967..01a0b74f 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -1,16 +1,15 @@ # == Schema Information -# Schema version: 20090317175355 # # Table name: orders # -# id :integer not null, primary key -# supplier_id :integer +# id :integer(4) not null, primary key +# supplier_id :integer(4) # note :text # starts :datetime # ends :datetime # state :string(255) default("open") -# lock_version :integer default(0), not null -# updated_by_user_id :integer +# lock_version :integer(4) default(0), not null +# updated_by_user_id :integer(4) # foodcoop_result :decimal(8, 2) # @@ -185,6 +184,10 @@ class Order < ActiveRecord::Base order_articles.each do |oa| oa.group_order_articles.each { |goa| goa.group_order_article_quantities.clear } end + + # Stats + # TODO: Move into background, if possible + ordergroups.each { |o| o.update_stats! } end end end diff --git a/app/models/order_article.rb b/app/models/order_article.rb index b2191d9d..e4d99898 100644 --- a/app/models/order_article.rb +++ b/app/models/order_article.rb @@ -1,16 +1,15 @@ # == Schema Information -# Schema version: 20090119155930 # # Table name: order_articles # -# id :integer not null, primary key -# order_id :integer default(0), not null -# article_id :integer default(0), not null -# quantity :integer default(0), not null -# tolerance :integer default(0), not null -# units_to_order :integer default(0), not null -# lock_version :integer default(0), not null -# article_price_id :integer +# id :integer(4) not null, primary key +# order_id :integer(4) default(0), not null +# article_id :integer(4) default(0), not null +# quantity :integer(4) default(0), not null +# tolerance :integer(4) default(0), not null +# units_to_order :integer(4) default(0), not null +# lock_version :integer(4) default(0), not null +# article_price_id :integer(4) # # An OrderArticle represents a single Article that is part of an Order. diff --git a/app/models/order_comment.rb b/app/models/order_comment.rb index 200a6872..2bd15d00 100644 --- a/app/models/order_comment.rb +++ b/app/models/order_comment.rb @@ -1,11 +1,10 @@ # == Schema Information -# Schema version: 20090119155930 # # Table name: order_comments # -# id :integer not null, primary key -# order_id :integer -# user_id :integer +# id :integer(4) not null, primary key +# order_id :integer(4) +# user_id :integer(4) # text :text # created_at :datetime # diff --git a/app/models/ordergroup.rb b/app/models/ordergroup.rb index 5c6b1050..65bf974b 100644 --- a/app/models/ordergroup.rb +++ b/app/models/ordergroup.rb @@ -1,29 +1,29 @@ # == Schema Information -# Schema version: 20090120184410 # # Table name: groups # -# id :integer not null, primary key +# id :integer(4) not null, primary key # type :string(255) default(""), not null # name :string(255) default(""), not null # description :string(255) -# account_balance :decimal(, ) default(0.0), not null +# account_balance :decimal(8, 2) default(0.0), not null # account_updated :datetime # created_on :datetime not null -# role_admin :boolean not null -# role_suppliers :boolean not null -# role_article_meta :boolean not null -# role_finance :boolean not null -# role_orders :boolean not null -# weekly_task :boolean -# weekday :integer +# role_admin :boolean(1) not null +# role_suppliers :boolean(1) not null +# role_article_meta :boolean(1) not null +# role_finance :boolean(1) not null +# role_orders :boolean(1) not null +# weekly_task :boolean(1) +# weekday :integer(4) # task_name :string(255) # task_description :string(255) -# task_required_users :integer default(1) +# task_required_users :integer(4) default(1) # deleted_at :datetime # contact_person :string(255) # contact_phone :string(255) # contact_address :string(255) +# stats :text # # Ordergroups can order, they are "children" of the class Group @@ -34,6 +34,7 @@ class Ordergroup < Group acts_as_paranoid # Avoid deleting the ordergroup for consistency of order-results extend ActiveSupport::Memoizable # Ability to cache method results. Use memoize :expensive_method + serialize :stats has_many :financial_transactions, :order => "created_on DESC" has_many :group_orders @@ -41,6 +42,8 @@ class Ordergroup < Group validates_numericality_of :account_balance, :message => 'ist keine gültige Zahl' + after_create :update_stats! + def contact "#{contact_phone} (#{contact_person})" end @@ -76,6 +79,23 @@ class Ordergroup < Group end end + def update_stats! + time = 6.month.ago + jobs = users.collect { |u| u.tasks.done.all(:conditions => ["updated_on > ?", time]).size }.sum + orders_sum = group_orders.collect { |go| go.price if go.order.ends > time }.sum + update_attribute(:stats, {:jobs_size => jobs, :orders_sum => orders_sum}) + end + + def avg_jobs_per_euro + stats[:orders_sum] != 0 ? stats[:jobs_size].to_f / stats[:orders_sum].to_f : 0 + end + + # Global average + def self.avg_jobs_per_euro + stats = Ordergroup.all.collect(&:stats) + stats.collect {|s| s[:jobs_size].to_f }.sum / stats.collect {|s| s[:orders_sum].to_f }.sum + end + private # If this order group's account balance is made negative by the given/last transaction, diff --git a/app/models/stock_article.rb b/app/models/stock_article.rb index c3da8405..020ebf10 100644 --- a/app/models/stock_article.rb +++ b/app/models/stock_article.rb @@ -1,28 +1,27 @@ # == Schema Information -# Schema version: 20090120184410 # # Table name: articles # -# id :integer not null, primary key +# id :integer(4) not null, primary key # name :string(255) default(""), not null -# supplier_id :integer default(0), not null -# article_category_id :integer default(0), not null +# supplier_id :integer(4) default(0), not null +# article_category_id :integer(4) default(0), not null # unit :string(255) default(""), not null # note :string(255) -# availability :boolean default(TRUE), not null +# availability :boolean(1) default(TRUE), not null # manufacturer :string(255) # origin :string(255) # shared_updated_on :datetime -# price :decimal(, ) +# price :decimal(8, 2) # tax :float -# deposit :decimal(, ) default(0.0) -# unit_quantity :integer default(1), not null +# deposit :decimal(8, 2) default(0.0) +# unit_quantity :integer(4) default(1), not null # order_number :string(255) # created_at :datetime # updated_at :datetime -# quantity :integer default(0) # deleted_at :datetime # type :string(255) +# quantity :integer(4) default(0) # class StockArticle < Article diff --git a/app/models/stock_change.rb b/app/models/stock_change.rb index a89ba7ee..ca008880 100644 --- a/app/models/stock_change.rb +++ b/app/models/stock_change.rb @@ -1,15 +1,14 @@ # == Schema Information -# Schema version: 20090317175355 # # Table name: stock_changes # -# id :integer not null, primary key -# delivery_id :integer -# order_id :integer -# stock_article_id :integer -# quantity :integer default(0) +# id :integer(4) not null, primary key +# delivery_id :integer(4) +# order_id :integer(4) +# stock_article_id :integer(4) +# quantity :integer(4) default(0) # created_at :datetime -# stock_taking_id :integer +# stock_taking_id :integer(4) # class StockChange < ActiveRecord::Base diff --git a/app/models/stock_taking.rb b/app/models/stock_taking.rb index d0c9fae2..fb91a2fc 100644 --- a/app/models/stock_taking.rb +++ b/app/models/stock_taking.rb @@ -1,9 +1,8 @@ # == Schema Information -# Schema version: 20090317175355 # # Table name: stock_takings # -# id :integer not null, primary key +# id :integer(4) not null, primary key # date :date # note :text # created_at :datetime diff --git a/app/models/supplier.rb b/app/models/supplier.rb index 9701cb6a..bb99d60b 100644 --- a/app/models/supplier.rb +++ b/app/models/supplier.rb @@ -1,9 +1,8 @@ # == Schema Information -# Schema version: 20090119155930 # # Table name: suppliers # -# id :integer not null, primary key +# id :integer(4) not null, primary key # name :string(255) default(""), not null # address :string(255) default(""), not null # phone :string(255) default(""), not null @@ -16,7 +15,7 @@ # delivery_days :string(255) # order_howto :string(255) # note :string(255) -# shared_supplier_id :integer +# shared_supplier_id :integer(4) # min_order_quantity :string(255) # deleted_at :datetime # diff --git a/app/models/task.rb b/app/models/task.rb index 4e3ffec0..b47b4f0d 100644 --- a/app/models/task.rb +++ b/app/models/task.rb @@ -1,18 +1,17 @@ # == Schema Information -# Schema version: 20090119155930 # # Table name: tasks # -# id :integer not null, primary key +# id :integer(4) not null, primary key # name :string(255) default(""), not null # description :string(255) # due_date :date -# done :boolean -# workgroup_id :integer -# assigned :boolean +# done :boolean(1) +# workgroup_id :integer(4) +# assigned :boolean(1) # created_on :datetime not null # updated_on :datetime not null -# required_users :integer default(1) +# required_users :integer(4) default(1) # class Task < ActiveRecord::Base @@ -28,7 +27,8 @@ class Task < ActiveRecord::Base attr_protected :users validates_length_of :name, :minimum => 3 - + + after_save :update_ordergroup_stats def is_assigned?(user) self.assignments.detect {|ass| ass.user_id == user.id } @@ -78,4 +78,12 @@ class Task < ActiveRecord::Base def user_list @user_list ||= users.collect(&:nick).join(", ") end + + private + + def update_ordergroup_stats + if done + users.each { |u| u.ordergroup.update_stats! } + end + end end diff --git a/app/models/user.rb b/app/models/user.rb index 7fa600bf..1253a81f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,9 +1,8 @@ # == Schema Information -# Schema version: 20090120184410 # # Table name: users # -# id :integer not null, primary key +# id :integer(4) not null, primary key # nick :string(255) default(""), not null # password_hash :string(255) default(""), not null # password_salt :string(255) default(""), not null diff --git a/app/models/workgroup.rb b/app/models/workgroup.rb index 56d0e897..cdc628bd 100644 --- a/app/models/workgroup.rb +++ b/app/models/workgroup.rb @@ -1,29 +1,29 @@ # == Schema Information -# Schema version: 20090120184410 # # Table name: groups # -# id :integer not null, primary key +# id :integer(4) not null, primary key # type :string(255) default(""), not null # name :string(255) default(""), not null # description :string(255) -# account_balance :decimal(, ) default(0.0), not null +# account_balance :decimal(8, 2) default(0.0), not null # account_updated :datetime # created_on :datetime not null -# role_admin :boolean not null -# role_suppliers :boolean not null -# role_article_meta :boolean not null -# role_finance :boolean not null -# role_orders :boolean not null -# weekly_task :boolean -# weekday :integer +# role_admin :boolean(1) not null +# role_suppliers :boolean(1) not null +# role_article_meta :boolean(1) not null +# role_finance :boolean(1) not null +# role_orders :boolean(1) not null +# weekly_task :boolean(1) +# weekday :integer(4) # task_name :string(255) # task_description :string(255) -# task_required_users :integer default(1) +# task_required_users :integer(4) default(1) # deleted_at :datetime # contact_person :string(255) # contact_phone :string(255) # contact_address :string(255) +# stats :text # class Workgroup < Group diff --git a/app/views/home/_stats.erb b/app/views/home/_stats.erb new file mode 100644 index 00000000..426c5709 --- /dev/null +++ b/app/views/home/_stats.erb @@ -0,0 +1,24 @@ +<% +max_width = 600 + +global_avg = Ordergroup.avg_jobs_per_euro +group_avg = @ordergroup.avg_jobs_per_euro.to_f + +length_of_global_bar = max_width / 2.0 +length_of_group_bar = (group_avg / global_avg) * length_of_global_bar + +length_of_group_bar = max_width if length_of_group_bar > max_width + +color = group_avg >= global_avg ? "#78b74e" : "red" +%> +Engagement Deiner Bestellgruppe +
+ <%= ((group_avg / global_avg) * 100).to_i -%><%= " Äpfel" if length_of_group_bar > 50 -%> +
+Durchschnittsengagement +
+ 100 Birnen +
+ + Abgebildet ist das Verhältnis von erledigten Aufgaben zu dem Bestellvolumen Deiner Bestellgruppe im Vergleich zum Durchschnitt in der Foodcoop. + \ No newline at end of file diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index 3e2bad73..0e7967f9 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -31,6 +31,12 @@ // Current orders = render :partial => 'shared/open_orders' + // Stats + .box_title + %h2 Engagement Deiner Bestellgruppe + .column_content + = render "stats" + - unless @messages.empty? .box_title %h2 Neuste Nachrichten @@ -49,9 +55,9 @@ | Verfügbares Guthaben: = number_to_currency(@ordergroup.get_available_funds()) - %span{:style => "color:grey"} - (zuletzt aktualisiert vor - = distance_of_time_in_words(Time.now, @ordergroup.account_updated) + "(n))" + %span.description + (Letzte Aktualisierung ist + = distance_of_time_in_words(Time.now, @ordergroup.account_updated) + " her)" %h3 Letzte Transaktionen %table %tr diff --git a/db/migrate/20090731132547_add_stats_to_groups.rb b/db/migrate/20090731132547_add_stats_to_groups.rb new file mode 100644 index 00000000..591a4ca6 --- /dev/null +++ b/db/migrate/20090731132547_add_stats_to_groups.rb @@ -0,0 +1,11 @@ +class AddStatsToGroups < ActiveRecord::Migration + def self.up + add_column :groups, :stats, :text + + Ordergroup.all.each { |o| o.update_stats! } + end + + def self.down + remove_column :groups, :stats + end +end diff --git a/db/schema.rb b/db/schema.rb index 8687cd15..b56e81fc 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -9,7 +9,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20090405131156) do +ActiveRecord::Schema.define(:version => 20090731132547) do create_table "article_categories", :force => true do |t| t.string "name", :default => "", :null => false @@ -135,6 +135,7 @@ ActiveRecord::Schema.define(:version => 20090405131156) do t.string "contact_person" t.string "contact_phone" t.string "contact_address" + t.text "stats" end add_index "groups", ["name"], :name => "index_groups_on_name", :unique => true diff --git a/public/stylesheets/main.css b/public/stylesheets/main.css index db2dbd7e..85036f26 100644 --- a/public/stylesheets/main.css +++ b/public/stylesheets/main.css @@ -81,6 +81,13 @@ option { span.click-me { cursor: pointer; } +.clear { + clear: both; } + +.description { + color: grey; + font-size: 0.9em; } + #login { margin: auto; width: 27em; @@ -161,31 +168,31 @@ span.click-me { background: #f5f5f5; padding: 0 10px 0px 5px; float: left; } - .menu ul, #start_nav ul { + .menu ul, #start_nav ul { list-style-type: none; margin: 0 0 0.2em 0; padding: 0; } - .menu ul li, #start_nav ul li { + .menu ul li, #start_nav ul li { border-bottom: 1px solid #dedede; color: #666; margin: 0.8em 0 0 0; font-weight: bold; } - .menu ul li a:link, .menu ul li a:visited, #start_nav ul li a:link, #start_nav ul li a:visited { + .menu ul li a:link, .menu ul li a:visited, #start_nav ul li a:link, #start_nav ul li a:visited { display: block; padding: 0.25em 1em; text-decoration: none; width: 12em; } - .menu ul li a:hover, .menu ul li a:focus, #start_nav ul li a:hover, #start_nav ul li a:focus { + .menu ul li a:hover, .menu ul li a:focus, #start_nav ul li a:hover, #start_nav ul li a:focus { background-color: #e3e3e3; } - .menu ul li ul, #start_nav ul li ul { + .menu ul li ul, #start_nav ul li ul { margin: 0; padding: 0; } - .menu ul li ul li, #start_nav ul li ul li { + .menu ul li ul li, #start_nav ul li ul li { border-top: 1px solid #dedede; border-bottom: none; margin: 0; font-weight: normal; } - .menu ul li ul li a:link, .menu ul li ul li a:visited, #start_nav ul li ul li a:link, #start_nav ul li ul li a:visited { + .menu ul li ul li a:link, .menu ul li ul li a:visited, #start_nav ul li ul li a:link, #start_nav ul li ul li a:visited { width: 11.5em; padding: 0 1em 0.1em 1.5em; font-weight: normal; @@ -433,3 +440,11 @@ ul.autocomplete .informal { position: relative; top: -1em; left: 5%; } + +.stats-bar { + height: 20px; + min-width: 10px; + border: 1px solid #DDDDDD; + background-color: #fff; + text-align: center; + margin: 0 10px 10px 0; } diff --git a/public/stylesheets/print.css b/public/stylesheets/print.css index 14afed69..2dee312b 100644 --- a/public/stylesheets/print.css +++ b/public/stylesheets/print.css @@ -81,6 +81,13 @@ option { span.click-me { cursor: pointer; } +.clear { + clear: both; } + +.description { + color: grey; + font-size: 0.9em; } + #login { margin: auto; width: 27em; @@ -161,31 +168,31 @@ span.click-me { background: #f5f5f5; padding: 0 10px 0px 5px; float: left; } - .menu ul, #start_nav ul { + .menu ul, #start_nav ul { list-style-type: none; margin: 0 0 0.2em 0; padding: 0; } - .menu ul li, #start_nav ul li { + .menu ul li, #start_nav ul li { border-bottom: 1px solid #dedede; color: #666; margin: 0.8em 0 0 0; font-weight: bold; } - .menu ul li a:link, .menu ul li a:visited, #start_nav ul li a:link, #start_nav ul li a:visited { + .menu ul li a:link, .menu ul li a:visited, #start_nav ul li a:link, #start_nav ul li a:visited { display: block; padding: 0.25em 1em; text-decoration: none; width: 12em; } - .menu ul li a:hover, .menu ul li a:focus, #start_nav ul li a:hover, #start_nav ul li a:focus { + .menu ul li a:hover, .menu ul li a:focus, #start_nav ul li a:hover, #start_nav ul li a:focus { background-color: #e3e3e3; } - .menu ul li ul, #start_nav ul li ul { + .menu ul li ul, #start_nav ul li ul { margin: 0; padding: 0; } - .menu ul li ul li, #start_nav ul li ul li { + .menu ul li ul li, #start_nav ul li ul li { border-top: 1px solid #dedede; border-bottom: none; margin: 0; font-weight: normal; } - .menu ul li ul li a:link, .menu ul li ul li a:visited, #start_nav ul li ul li a:link, #start_nav ul li ul li a:visited { + .menu ul li ul li a:link, .menu ul li ul li a:visited, #start_nav ul li ul li a:link, #start_nav ul li ul li a:visited { width: 11.5em; padding: 0 1em 0.1em 1.5em; font-weight: normal; @@ -434,6 +441,14 @@ ul.autocomplete .informal { top: -1em; left: 5%; } +.stats-bar { + height: 20px; + min-width: 10px; + border: 1px solid #DDDDDD; + background-color: #fff; + text-align: center; + margin: 0 10px 10px 0; } + #logininfo, #header, #footer { display: none; } diff --git a/public/stylesheets/sass/main.sass b/public/stylesheets/sass/main.sass index cc09abaf..021bb87f 100644 --- a/public/stylesheets/sass/main.sass +++ b/public/stylesheets/sass/main.sass @@ -90,6 +90,13 @@ option span.click-me cursor: pointer + +.clear + clear: both + +.description + color: grey + font-size: 0.9em // ********************************* loginpage #login @@ -479,4 +486,13 @@ ul.autocomplete #element_navigation position: relative top: -1em - left: 5% \ No newline at end of file + left: 5% + +// group stats +.stats-bar + height: 20px + min-width: 10px + border: 1px solid #DDDDDD + background-color: #fff + text-align: center + margin: 0 10px 10px 0 \ No newline at end of file diff --git a/test/fixtures/article_categories.yml b/test/fixtures/article_categories.yml index 6ed49db0..24b95c28 100644 --- a/test/fixtures/article_categories.yml +++ b/test/fixtures/article_categories.yml @@ -1,9 +1,8 @@ # == Schema Information -# Schema version: 20090119155930 # # Table name: article_categories # -# id :integer not null, primary key +# id :integer(4) not null, primary key # name :string(255) default(""), not null # description :string(255) # diff --git a/test/fixtures/article_prices.yml b/test/fixtures/article_prices.yml index 429e3e23..d22c2a64 100644 --- a/test/fixtures/article_prices.yml +++ b/test/fixtures/article_prices.yml @@ -1,14 +1,13 @@ # == Schema Information -# Schema version: 20090119155930 # # Table name: article_prices # -# id :integer not null, primary key -# article_id :integer +# id :integer(4) not null, primary key +# article_id :integer(4) # price :decimal(8, 2) default(0.0), not null # tax :decimal(8, 2) default(0.0), not null # deposit :decimal(8, 2) default(0.0), not null -# unit_quantity :integer +# unit_quantity :integer(4) # created_at :datetime # diff --git a/test/fixtures/articles.yml b/test/fixtures/articles.yml index 00162119..3da09856 100644 --- a/test/fixtures/articles.yml +++ b/test/fixtures/articles.yml @@ -1,28 +1,27 @@ # == Schema Information -# Schema version: 20090317175355 # # Table name: articles # -# id :integer not null, primary key +# id :integer(4) not null, primary key # name :string(255) default(""), not null -# supplier_id :integer default(0), not null -# article_category_id :integer default(0), not null +# supplier_id :integer(4) default(0), not null +# article_category_id :integer(4) default(0), not null # unit :string(255) default(""), not null # note :string(255) -# availability :boolean default(TRUE), not null +# availability :boolean(1) default(TRUE), not null # manufacturer :string(255) # origin :string(255) # shared_updated_on :datetime -# price :decimal(, ) +# price :decimal(8, 2) # tax :float -# deposit :decimal(, ) default(0.0) -# unit_quantity :integer default(1), not null +# deposit :decimal(8, 2) default(0.0) +# unit_quantity :integer(4) default(1), not null # order_number :string(255) # created_at :datetime # updated_at :datetime -# quantity :integer default(0) # deleted_at :datetime # type :string(255) +# quantity :integer(4) default(0) # # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html diff --git a/test/fixtures/assignments.yml b/test/fixtures/assignments.yml index 075df226..a3d60c20 100644 --- a/test/fixtures/assignments.yml +++ b/test/fixtures/assignments.yml @@ -1,12 +1,11 @@ # == Schema Information -# Schema version: 20090119155930 # # Table name: assignments # -# id :integer not null, primary key -# user_id :integer default(0), not null -# task_id :integer default(0), not null -# accepted :boolean +# id :integer(4) not null, primary key +# user_id :integer(4) default(0), not null +# task_id :integer(4) default(0), not null +# accepted :boolean(1) # # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html diff --git a/test/fixtures/financial_transactions.yml b/test/fixtures/financial_transactions.yml index 247d2451..b4355257 100644 --- a/test/fixtures/financial_transactions.yml +++ b/test/fixtures/financial_transactions.yml @@ -1,13 +1,12 @@ # == Schema Information -# Schema version: 20090119155930 # # Table name: financial_transactions # -# id :integer not null, primary key -# ordergroup_id :integer default(0), not null +# id :integer(4) not null, primary key +# ordergroup_id :integer(4) default(0), not null # amount :decimal(8, 2) default(0.0), not null -# note :text not null -# user_id :integer default(0), not null +# note :text default(""), not null +# user_id :integer(4) default(0), not null # created_on :datetime not null # diff --git a/test/fixtures/group_order_article_quantities.yml b/test/fixtures/group_order_article_quantities.yml index fb9fbf77..177fb61c 100644 --- a/test/fixtures/group_order_article_quantities.yml +++ b/test/fixtures/group_order_article_quantities.yml @@ -1,12 +1,11 @@ # == Schema Information -# Schema version: 20090119155930 # # Table name: group_order_article_quantities # -# id :integer not null, primary key -# group_order_article_id :integer default(0), not null -# quantity :integer default(0) -# tolerance :integer default(0) +# id :integer(4) not null, primary key +# group_order_article_id :integer(4) default(0), not null +# quantity :integer(4) default(0) +# tolerance :integer(4) default(0) # created_on :datetime not null # diff --git a/test/fixtures/groups.yml b/test/fixtures/groups.yml index 8ab4f5f1..3ffb9bab 100644 --- a/test/fixtures/groups.yml +++ b/test/fixtures/groups.yml @@ -1,29 +1,29 @@ # == Schema Information -# Schema version: 20090120184410 # # Table name: groups # -# id :integer not null, primary key +# id :integer(4) not null, primary key # type :string(255) default(""), not null # name :string(255) default(""), not null # description :string(255) -# account_balance :decimal(, ) default(0.0), not null +# account_balance :decimal(8, 2) default(0.0), not null # account_updated :datetime # created_on :datetime not null -# role_admin :boolean not null -# role_suppliers :boolean not null -# role_article_meta :boolean not null -# role_finance :boolean not null -# role_orders :boolean not null -# weekly_task :boolean -# weekday :integer +# role_admin :boolean(1) not null +# role_suppliers :boolean(1) not null +# role_article_meta :boolean(1) not null +# role_finance :boolean(1) not null +# role_orders :boolean(1) not null +# weekly_task :boolean(1) +# weekday :integer(4) # task_name :string(255) # task_description :string(255) -# task_required_users :integer default(1) +# task_required_users :integer(4) default(1) # deleted_at :datetime # contact_person :string(255) # contact_phone :string(255) # contact_address :string(255) +# stats :text # # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html diff --git a/test/fixtures/memberships.yml b/test/fixtures/memberships.yml index 2d6d3c9d..cabe2417 100644 --- a/test/fixtures/memberships.yml +++ b/test/fixtures/memberships.yml @@ -1,11 +1,10 @@ # == Schema Information -# Schema version: 20090119155930 # # Table name: memberships # -# id :integer not null, primary key -# group_id :integer default(0), not null -# user_id :integer default(0), not null +# id :integer(4) not null, primary key +# group_id :integer(4) default(0), not null +# user_id :integer(4) default(0), not null # # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html diff --git a/test/fixtures/messages.yml b/test/fixtures/messages.yml index 88f2ab27..3305dbca 100644 --- a/test/fixtures/messages.yml +++ b/test/fixtures/messages.yml @@ -1,15 +1,14 @@ # == Schema Information -# Schema version: 20090119155930 # # Table name: messages # -# id :integer not null, primary key -# sender_id :integer +# id :integer(4) not null, primary key +# sender_id :integer(4) # recipients_ids :text # subject :string(255) not null # body :text -# email_state :integer default(0), not null -# private :boolean +# email_state :integer(4) default(0), not null +# private :boolean(1) # created_at :datetime # diff --git a/test/fixtures/order_comments.yml b/test/fixtures/order_comments.yml index f3816841..743aa8ee 100644 --- a/test/fixtures/order_comments.yml +++ b/test/fixtures/order_comments.yml @@ -1,11 +1,10 @@ # == Schema Information -# Schema version: 20090119155930 # # Table name: order_comments # -# id :integer not null, primary key -# order_id :integer -# user_id :integer +# id :integer(4) not null, primary key +# order_id :integer(4) +# user_id :integer(4) # text :text # created_at :datetime # diff --git a/test/fixtures/orders.yml b/test/fixtures/orders.yml index e29b13f8..ce66a642 100644 --- a/test/fixtures/orders.yml +++ b/test/fixtures/orders.yml @@ -1,16 +1,15 @@ # == Schema Information -# Schema version: 20090317175355 # # Table name: orders # -# id :integer not null, primary key -# supplier_id :integer +# id :integer(4) not null, primary key +# supplier_id :integer(4) # note :text # starts :datetime # ends :datetime # state :string(255) default("open") -# lock_version :integer default(0), not null -# updated_by_user_id :integer +# lock_version :integer(4) default(0), not null +# updated_by_user_id :integer(4) # foodcoop_result :decimal(8, 2) # diff --git a/test/fixtures/stock_changes.yml b/test/fixtures/stock_changes.yml index 26fe5a89..1ef1bb6f 100644 --- a/test/fixtures/stock_changes.yml +++ b/test/fixtures/stock_changes.yml @@ -1,15 +1,14 @@ # == Schema Information -# Schema version: 20090317175355 # # Table name: stock_changes # -# id :integer not null, primary key -# delivery_id :integer -# order_id :integer -# stock_article_id :integer -# quantity :integer default(0) +# id :integer(4) not null, primary key +# delivery_id :integer(4) +# order_id :integer(4) +# stock_article_id :integer(4) +# quantity :integer(4) default(0) # created_at :datetime -# stock_taking_id :integer +# stock_taking_id :integer(4) # # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html diff --git a/test/fixtures/stock_takings.yml b/test/fixtures/stock_takings.yml index 1d32b4b5..aea5d65c 100644 --- a/test/fixtures/stock_takings.yml +++ b/test/fixtures/stock_takings.yml @@ -1,9 +1,8 @@ # == Schema Information -# Schema version: 20090317175355 # # Table name: stock_takings # -# id :integer not null, primary key +# id :integer(4) not null, primary key # date :date # note :text # created_at :datetime diff --git a/test/fixtures/suppliers.yml b/test/fixtures/suppliers.yml index 201290c1..eda7c97c 100644 --- a/test/fixtures/suppliers.yml +++ b/test/fixtures/suppliers.yml @@ -1,5 +1,4 @@ # == Schema Information -# Schema version: 20090317175355 # # Table name: suppliers # diff --git a/test/fixtures/tasks.yml b/test/fixtures/tasks.yml index 9bf6cece..755f4bce 100644 --- a/test/fixtures/tasks.yml +++ b/test/fixtures/tasks.yml @@ -1,18 +1,17 @@ # == Schema Information -# Schema version: 20090119155930 # # Table name: tasks # -# id :integer not null, primary key +# id :integer(4) not null, primary key # name :string(255) default(""), not null # description :string(255) # due_date :date -# done :boolean -# workgroup_id :integer -# assigned :boolean +# done :boolean(1) +# workgroup_id :integer(4) +# assigned :boolean(1) # created_on :datetime not null # updated_on :datetime not null -# required_users :integer default(1) +# required_users :integer(4) default(1) # -# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html \ No newline at end of file +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml index 707f01c1..5cf891ae 100644 --- a/test/fixtures/users.yml +++ b/test/fixtures/users.yml @@ -1,9 +1,8 @@ # == Schema Information -# Schema version: 20090120184410 # # Table name: users # -# id :integer not null, primary key +# id :integer(4) not null, primary key # nick :string(255) default(""), not null # password_hash :string(255) default(""), not null # password_salt :string(255) default(""), not null diff --git a/test/unit/article_category_test.rb b/test/unit/article_category_test.rb index 79f216ff..57ec38dd 100644 --- a/test/unit/article_category_test.rb +++ b/test/unit/article_category_test.rb @@ -1,9 +1,8 @@ # == Schema Information -# Schema version: 20090317175355 # # Table name: article_categories # -# id :integer not null, primary key +# id :integer(4) not null, primary key # name :string(255) default(""), not null # description :string(255) # diff --git a/test/unit/article_price_test.rb b/test/unit/article_price_test.rb index d9f79a8e..1573cbf7 100644 --- a/test/unit/article_price_test.rb +++ b/test/unit/article_price_test.rb @@ -1,14 +1,13 @@ # == Schema Information -# Schema version: 20090317175355 # # Table name: article_prices # -# id :integer not null, primary key -# article_id :integer +# id :integer(4) not null, primary key +# article_id :integer(4) # price :decimal(8, 2) default(0.0), not null # tax :decimal(8, 2) default(0.0), not null # deposit :decimal(8, 2) default(0.0), not null -# unit_quantity :integer +# unit_quantity :integer(4) # created_at :datetime # diff --git a/test/unit/article_test.rb b/test/unit/article_test.rb index ee965128..4fed301e 100644 --- a/test/unit/article_test.rb +++ b/test/unit/article_test.rb @@ -1,28 +1,27 @@ # == Schema Information -# Schema version: 20090317175355 # # Table name: articles # -# id :integer not null, primary key +# id :integer(4) not null, primary key # name :string(255) default(""), not null -# supplier_id :integer default(0), not null -# article_category_id :integer default(0), not null +# supplier_id :integer(4) default(0), not null +# article_category_id :integer(4) default(0), not null # unit :string(255) default(""), not null # note :string(255) -# availability :boolean default(TRUE), not null +# availability :boolean(1) default(TRUE), not null # manufacturer :string(255) # origin :string(255) # shared_updated_on :datetime -# price :decimal(, ) +# price :decimal(8, 2) # tax :float -# deposit :decimal(, ) default(0.0) -# unit_quantity :integer default(1), not null +# deposit :decimal(8, 2) default(0.0) +# unit_quantity :integer(4) default(1), not null # order_number :string(255) # created_at :datetime # updated_at :datetime -# quantity :integer default(0) # deleted_at :datetime # type :string(255) +# quantity :integer(4) default(0) # require File.dirname(__FILE__) + '/../test_helper' diff --git a/test/unit/assignment_test.rb b/test/unit/assignment_test.rb index 27769a44..fb8103a6 100644 --- a/test/unit/assignment_test.rb +++ b/test/unit/assignment_test.rb @@ -1,12 +1,11 @@ # == Schema Information -# Schema version: 20090317175355 # # Table name: assignments # -# id :integer not null, primary key -# user_id :integer default(0), not null -# task_id :integer default(0), not null -# accepted :boolean +# id :integer(4) not null, primary key +# user_id :integer(4) default(0), not null +# task_id :integer(4) default(0), not null +# accepted :boolean(1) # require File.dirname(__FILE__) + '/../test_helper' diff --git a/test/unit/financial_transaction_test.rb b/test/unit/financial_transaction_test.rb index b4b26ed2..871023b5 100644 --- a/test/unit/financial_transaction_test.rb +++ b/test/unit/financial_transaction_test.rb @@ -1,13 +1,12 @@ # == Schema Information -# Schema version: 20090317175355 # # Table name: financial_transactions # -# id :integer not null, primary key -# ordergroup_id :integer default(0), not null +# id :integer(4) not null, primary key +# ordergroup_id :integer(4) default(0), not null # amount :decimal(8, 2) default(0.0), not null -# note :text not null -# user_id :integer default(0), not null +# note :text default(""), not null +# user_id :integer(4) default(0), not null # created_on :datetime not null # diff --git a/test/unit/group_order_article_quantity_test.rb b/test/unit/group_order_article_quantity_test.rb index 83971972..8532807f 100644 --- a/test/unit/group_order_article_quantity_test.rb +++ b/test/unit/group_order_article_quantity_test.rb @@ -1,12 +1,11 @@ # == Schema Information -# Schema version: 20090317175355 # # Table name: group_order_article_quantities # -# id :integer not null, primary key -# group_order_article_id :integer default(0), not null -# quantity :integer default(0) -# tolerance :integer default(0) +# id :integer(4) not null, primary key +# group_order_article_id :integer(4) default(0), not null +# quantity :integer(4) default(0) +# tolerance :integer(4) default(0) # created_on :datetime not null # diff --git a/test/unit/group_test.rb b/test/unit/group_test.rb index 3328b0e9..c4626cb0 100644 --- a/test/unit/group_test.rb +++ b/test/unit/group_test.rb @@ -1,29 +1,29 @@ # == Schema Information -# Schema version: 20090317175355 # # Table name: groups # -# id :integer not null, primary key +# id :integer(4) not null, primary key # type :string(255) default(""), not null # name :string(255) default(""), not null # description :string(255) -# account_balance :decimal(, ) default(0.0), not null +# account_balance :decimal(8, 2) default(0.0), not null # account_updated :datetime # created_on :datetime not null -# role_admin :boolean not null -# role_suppliers :boolean not null -# role_article_meta :boolean not null -# role_finance :boolean not null -# role_orders :boolean not null -# weekly_task :boolean -# weekday :integer +# role_admin :boolean(1) not null +# role_suppliers :boolean(1) not null +# role_article_meta :boolean(1) not null +# role_finance :boolean(1) not null +# role_orders :boolean(1) not null +# weekly_task :boolean(1) +# weekday :integer(4) # task_name :string(255) # task_description :string(255) -# task_required_users :integer default(1) +# task_required_users :integer(4) default(1) # deleted_at :datetime # contact_person :string(255) # contact_phone :string(255) # contact_address :string(255) +# stats :text # require File.dirname(__FILE__) + '/../test_helper' diff --git a/test/unit/membership_test.rb b/test/unit/membership_test.rb index 67237a15..9c152e97 100644 --- a/test/unit/membership_test.rb +++ b/test/unit/membership_test.rb @@ -1,11 +1,10 @@ # == Schema Information -# Schema version: 20090317175355 # # Table name: memberships # -# id :integer not null, primary key -# group_id :integer default(0), not null -# user_id :integer default(0), not null +# id :integer(4) not null, primary key +# group_id :integer(4) default(0), not null +# user_id :integer(4) default(0), not null # require File.dirname(__FILE__) + '/../test_helper' diff --git a/test/unit/order_comment_test.rb b/test/unit/order_comment_test.rb index 9536faf2..87b1531f 100644 --- a/test/unit/order_comment_test.rb +++ b/test/unit/order_comment_test.rb @@ -1,11 +1,10 @@ # == Schema Information -# Schema version: 20090317175355 # # Table name: order_comments # -# id :integer not null, primary key -# order_id :integer -# user_id :integer +# id :integer(4) not null, primary key +# order_id :integer(4) +# user_id :integer(4) # text :text # created_at :datetime # diff --git a/test/unit/order_test.rb b/test/unit/order_test.rb index 7ac351c4..0637d9a7 100644 --- a/test/unit/order_test.rb +++ b/test/unit/order_test.rb @@ -1,16 +1,15 @@ # == Schema Information -# Schema version: 20090317175355 # # Table name: orders # -# id :integer not null, primary key -# supplier_id :integer +# id :integer(4) not null, primary key +# supplier_id :integer(4) # note :text # starts :datetime # ends :datetime # state :string(255) default("open") -# lock_version :integer default(0), not null -# updated_by_user_id :integer +# lock_version :integer(4) default(0), not null +# updated_by_user_id :integer(4) # foodcoop_result :decimal(8, 2) # diff --git a/test/unit/stock_article_test.rb b/test/unit/stock_article_test.rb index 6de29c6a..a7ea983d 100644 --- a/test/unit/stock_article_test.rb +++ b/test/unit/stock_article_test.rb @@ -1,28 +1,27 @@ # == Schema Information -# Schema version: 20090317175355 # # Table name: articles # -# id :integer not null, primary key +# id :integer(4) not null, primary key # name :string(255) default(""), not null -# supplier_id :integer default(0), not null -# article_category_id :integer default(0), not null +# supplier_id :integer(4) default(0), not null +# article_category_id :integer(4) default(0), not null # unit :string(255) default(""), not null # note :string(255) -# availability :boolean default(TRUE), not null +# availability :boolean(1) default(TRUE), not null # manufacturer :string(255) # origin :string(255) # shared_updated_on :datetime -# price :decimal(, ) +# price :decimal(8, 2) # tax :float -# deposit :decimal(, ) default(0.0) -# unit_quantity :integer default(1), not null +# deposit :decimal(8, 2) default(0.0) +# unit_quantity :integer(4) default(1), not null # order_number :string(255) # created_at :datetime # updated_at :datetime -# quantity :integer default(0) # deleted_at :datetime # type :string(255) +# quantity :integer(4) default(0) # require 'test_helper' diff --git a/test/unit/stock_change_test.rb b/test/unit/stock_change_test.rb index 59928e43..706d478e 100644 --- a/test/unit/stock_change_test.rb +++ b/test/unit/stock_change_test.rb @@ -1,15 +1,14 @@ # == Schema Information -# Schema version: 20090317175355 # # Table name: stock_changes # -# id :integer not null, primary key -# delivery_id :integer -# order_id :integer -# stock_article_id :integer -# quantity :integer default(0) +# id :integer(4) not null, primary key +# delivery_id :integer(4) +# order_id :integer(4) +# stock_article_id :integer(4) +# quantity :integer(4) default(0) # created_at :datetime -# stock_taking_id :integer +# stock_taking_id :integer(4) # require 'test_helper' diff --git a/test/unit/stock_taking_test.rb b/test/unit/stock_taking_test.rb index 94d0b71a..e088facf 100644 --- a/test/unit/stock_taking_test.rb +++ b/test/unit/stock_taking_test.rb @@ -1,9 +1,8 @@ # == Schema Information -# Schema version: 20090317175355 # # Table name: stock_takings # -# id :integer not null, primary key +# id :integer(4) not null, primary key # date :date # note :text # created_at :datetime diff --git a/test/unit/supplier_test.rb b/test/unit/supplier_test.rb index 4b9c14cc..1d437b66 100644 --- a/test/unit/supplier_test.rb +++ b/test/unit/supplier_test.rb @@ -1,9 +1,8 @@ # == Schema Information -# Schema version: 20090317175355 # # Table name: suppliers # -# id :integer not null, primary key +# id :integer(4) not null, primary key # name :string(255) default(""), not null # address :string(255) default(""), not null # phone :string(255) default(""), not null @@ -16,7 +15,7 @@ # delivery_days :string(255) # order_howto :string(255) # note :string(255) -# shared_supplier_id :integer +# shared_supplier_id :integer(4) # min_order_quantity :string(255) # deleted_at :datetime # diff --git a/test/unit/task_test.rb b/test/unit/task_test.rb index 0a2d416b..7046ed75 100644 --- a/test/unit/task_test.rb +++ b/test/unit/task_test.rb @@ -1,18 +1,17 @@ # == Schema Information -# Schema version: 20090317175355 # # Table name: tasks # -# id :integer not null, primary key +# id :integer(4) not null, primary key # name :string(255) default(""), not null # description :string(255) # due_date :date -# done :boolean -# workgroup_id :integer -# assigned :boolean +# done :boolean(1) +# workgroup_id :integer(4) +# assigned :boolean(1) # created_on :datetime not null # updated_on :datetime not null -# required_users :integer default(1) +# required_users :integer(4) default(1) # require File.dirname(__FILE__) + '/../test_helper' diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index a19e4695..76c8aeb4 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -1,9 +1,8 @@ # == Schema Information -# Schema version: 20090317175355 # # Table name: users # -# id :integer not null, primary key +# id :integer(4) not null, primary key # nick :string(255) default(""), not null # password_hash :string(255) default(""), not null # password_salt :string(255) default(""), not null diff --git a/test/unit/workgroup_test.rb b/test/unit/workgroup_test.rb index 38cc57f3..bcac7c7c 100644 --- a/test/unit/workgroup_test.rb +++ b/test/unit/workgroup_test.rb @@ -1,29 +1,29 @@ # == Schema Information -# Schema version: 20090317175355 # # Table name: groups # -# id :integer not null, primary key +# id :integer(4) not null, primary key # type :string(255) default(""), not null # name :string(255) default(""), not null # description :string(255) -# account_balance :decimal(, ) default(0.0), not null +# account_balance :decimal(8, 2) default(0.0), not null # account_updated :datetime # created_on :datetime not null -# role_admin :boolean not null -# role_suppliers :boolean not null -# role_article_meta :boolean not null -# role_finance :boolean not null -# role_orders :boolean not null -# weekly_task :boolean -# weekday :integer +# role_admin :boolean(1) not null +# role_suppliers :boolean(1) not null +# role_article_meta :boolean(1) not null +# role_finance :boolean(1) not null +# role_orders :boolean(1) not null +# weekly_task :boolean(1) +# weekday :integer(4) # task_name :string(255) # task_description :string(255) -# task_required_users :integer default(1) +# task_required_users :integer(4) default(1) # deleted_at :datetime # contact_person :string(255) # contact_phone :string(255) # contact_address :string(255) +# stats :text # require 'test_helper'