Commit 04bb4358 authored by Kaspar Vollenweider's avatar Kaspar Vollenweider

Merge branch 'features/update_and_improove_performance_reports' into 'develop'

Features/update and improove performance reports

See merge request !470
parents 6d9d1cd1 125d379f
Pipeline #14537 passed with stage
in 28 minutes and 25 seconds
......@@ -7,20 +7,29 @@
.table {
margin-bottom: 30px;
margin-top: 15px;
}
td {
&:nth-child(2) {
padding-right: 20px;
text-align: right;
width: 90px;
td,
th {
text-align: center;
width: 10%;
&:first-child {
text-align: left;
width: 20%;
}
}
td {
&:last-child {
font-weight: 700;
}
}
}
.active {
td {
border-bottom: 0;
font-weight: bold;
border-bottom: 1px solid $gray-light;
font-weight: 800;
}
& + tr td {
......
......@@ -29,8 +29,10 @@ module ApplicationHelper
end
end
def boostrap_row
content_tag :div, class: 'row' do
def boostrap_row(add_class = nil)
row_class = 'row'
row_class += " #{add_class}" if add_class.present?
content_tag :div, class: row_class do
yield
end
end
......
module NavigationAndButtonHelper
def form_navigation_btn(action, cols: 12, with_row: true, md_cols: nil, with_col: false)
def form_navigation_btn(action, cols: 12, with_row: true, md_cols: nil, with_col: false,
add_class: nil)
button = make_nav_button(action)
button = bootstrap_col(cols, md_cols) { button } if with_col || with_row
button = boostrap_row { button } if with_row
button = boostrap_row(add_class) { button } if with_row
button
end
......
......@@ -27,7 +27,9 @@ class ApplicationRecord < ActiveRecord::Base
}
scope :created_before, ->(max_time) { date_before(:created_at, max_time) }
scope :created_at_or_before, ->(max_time) { date_at_or_before(:created_at, max_time) }
scope :created_after, ->(min_time) { date_after(:created_at, min_time) }
scope :created_at_or_after, ->(min_time) { date_at_or_after(:created_at, min_time) }
scope :created_between, lambda { |start_date, end_date|
date_between(:created_at, start_date, end_date)
}
......
......@@ -5,7 +5,7 @@ class Client < ApplicationRecord
include ZuerichScopes
include ImportRelation
before_update :record_acceptance_change, if: :going_to_change_to_resigned?
before_update :record_acceptance_change, if: :will_save_change_to_acceptance?
enum acceptance: { accepted: 0, rejected: 1, resigned: 2 }
enum cost_unit: { city: 0, municipality: 1, canton: 2 }
......@@ -58,6 +58,7 @@ class Client < ApplicationRecord
scope :with_inactive_assignment, lambda {
left_outer_joins(:assignment)
.accepted
.where('assignments.period_end < ?', Time.zone.today)
}
......@@ -73,6 +74,14 @@ class Client < ApplicationRecord
accepted.without_assignment.or(with_inactive_assignment)
}
scope :resigned_between, lambda { |start_date, end_date|
date_between(:resigned_at, start_date, end_date)
}
scope :resigned_between, lambda { |start_date, end_date|
date_between(:resigned_at, start_date, end_date)
}
def terminatable?
assignment.blank? || assignment.no_period? || assignment.ended?
end
......@@ -119,11 +128,7 @@ class Client < ApplicationRecord
private
def going_to_change_to_resigned?
will_save_change_to_acceptance?(to: 'resigned')
end
def record_acceptance_change
self.resigned_on = Time.zone.today
self["#{acceptance}_at".to_sym] = Time.zone.now
end
end
......@@ -16,7 +16,7 @@ module FeedbackTrialFeedbackCommon
}
scope :submitted_before, lambda { |submitted_at|
created_before(submitted_at)
created_after(submitted_at)
}
scope :author_isnt_volunteer, lambda {
......
......@@ -13,8 +13,8 @@ module TerminationScopes
date_at_or_after(:termination_submitted_at, time)
}
scope :termination_submitted_between, lambda { |time|
date_between_inclusion(:termination_submitted_at, time)
scope :termination_submitted_between, lambda { |start_date, end_date|
date_between_inclusion(:termination_submitted_at, start_date, end_date)
}
scope :unterminated, (-> { field_nil(:termination_verified_by_id) })
......
......@@ -11,7 +11,14 @@ class Feedback < ApplicationRecord
validates :comments, presence: true
scope :submitted_before, ->(submitted_at) { where('feedbacks.created_at > ?', submitted_at) }
scope :assignment, (-> { where(feedbackable_type: 'Assignment') })
scope :group_offer, (-> { where(feedbackable_type: 'GroupOffer') })
scope :from_assignments, lambda { |assignment_ids|
assignment.where(feedbackable_id: assignment_ids)
}
scope :from_group_offers, lambda { |group_offer_ids|
group_offer.where(feedbackable_id: group_offer_ids)
}
def assignment?
feedbackable_type == 'Assignment'
......
......@@ -56,6 +56,10 @@ class GroupOffer < ApplicationRecord
joins(:group_assignments).merge(GroupAssignment.end_within(start_date, end_date))
}
scope :started_group_assignments_between, lambda { |start_date, end_date|
joins(:group_assignments).merge(GroupAssignment.start_within(start_date, end_date))
}
scope :no_end, (-> { field_nil(:period_end) })
scope :has_end, (-> { field_not_nil(:period_end) })
scope :end_before, ->(date) { date_before(:period_end, date) }
......@@ -67,14 +71,6 @@ class GroupOffer < ApplicationRecord
date_between_inclusion(:period_end, start_date, end_date)
}
scope :active_group_assignments_between, lambda { |start_date, end_date|
joins(:group_assignments).merge(GroupAssignment.active_between(start_date, end_date))
}
scope :ended_group_assignments_between, lambda { |start_date, end_date|
joins(:group_assignments).merge(GroupAssignment.end_within(start_date, end_date))
}
def active_group_assignments_between?(start_date, end_date)
group_assignments.active_between(start_date, end_date).any?
end
......
......@@ -27,6 +27,15 @@ class Hour < ApplicationRecord
joins(:volunteer).where('volunteers.waive = FALSE')
}
scope :assignment, (-> { where(hourable_type: 'Assignment') })
scope :group_offer, (-> { where(hourable_type: 'GroupOffer') })
scope :from_assignments, lambda { |assignment_ids|
assignment.where(hourable_id: assignment_ids)
}
scope :from_group_offers, lambda { |group_offer_ids|
group_offer.where(hourable_id: group_offer_ids)
}
HOUR_RANGE = (1..8).to_a
MINUTE_RANGE = [0, 15, 30, 45].freeze
......
......@@ -5,85 +5,159 @@ class PerformanceReport < ApplicationRecord
validates :period_start, presence: true
validates :period_end, presence: true
def periods
@periods ||= [period_start.to_time.midnight, period_end.to_time.end_of_day]
end
def generate_report
period_all_year = period_start.all_year
if period_all_year.end == period_end && period_all_year.begin == period_start
self.year = period_start.year
end
self.report_content = {
global: global,
zuerich: zuerich,
group_offers: group_offers
volunteers: volunteer_performance,
clients: client_performance,
assignments: assignment_performance,
group_offers: group_offer_performance
}
end
def global
def volunteer_performance
volunteers = Volunteer.created_before(periods.last)
{
volunteers: volunteers,
clients: clients,
assignments: assignments
all: volunteers_stats(volunteers),
zurich: volunteers_stats(volunteers.zurich),
not_zurich: volunteers_stats(volunteers.not_zurich),
external: volunteers_stats(volunteers.external),
internal: volunteers_stats(volunteers.internal)
}
end
def zuerich
def volunteers_stats(volunteers)
assignment_active = volunteers.with_active_assignments_between(*periods).distinct.ids
group_active = volunteers.with_active_group_assignments_between(*periods).distinct.ids
active_both = assignment_active & group_active
only_group_active = group_active - active_both
only_assignment_active = assignment_active - active_both
active_total = assignment_active + group_active
hours = Hour.date_between(:meeting_date, *periods).where(volunteer_id: volunteers.ids)
feedbacks = Feedback.created_between(*periods).where(volunteer_id: volunteers.ids)
trial_feedbacks = TrialFeedback.created_between(*periods).where(volunteer_id: volunteers.ids)
{
volunteers: volunteers(true),
clients: clients(true),
assignments: assignments(true)
total: volunteers.count,
active_assignment: assignment_active.size,
active_group_assignment: group_active.size,
active_both: active_both.size,
active_total: active_total.uniq.size,
only_assignment_active: only_assignment_active.size,
only_group_active: only_group_active.size,
created: volunteers.created_after(periods.first).count,
resigned: volunteers.resigned_between(*periods).count,
inactive: volunteers.where.not(id: assignment_active + group_active).distinct.count,
assignment_hour_records: hours.assignment.count,
assignment_hours: hours.assignment.sum(:hours) + (hours.assignment.sum(:minutes) / 60.0),
group_offer_hour_records: hours.group_offer.count,
group_offer_hours: hours.group_offer.sum(:hours) + (hours.group_offer.sum(:minutes) / 60.0),
total_hour_records: hours.count,
total_hours: hours.sum(:hours) + (hours.sum(:minutes) / 60.0),
assignment_feedbacks: feedbacks.assignment.count,
group_offer_feedbacks: feedbacks.group_offer.count,
total_feedbacks: feedbacks.count,
assignment_trial_feedbacks: trial_feedbacks.assignment.count,
group_offer_trial_feedbacks: trial_feedbacks.group_offer.count,
total_trial_feedbacks: trial_feedbacks.count
}
end
def volunteers(zurich = false)
volunteers = Volunteer.created_before(period_end)
volunteers = extern ? volunteers.external : volunteers.internal
volunteers = zurich ? volunteers.zurich : volunteers.not_zurich
active_ids = volunteers.with_active_assignments_between(period_start, period_end).ids
active_ids += volunteers.with_active_group_assignments_between(period_start, period_end).ids
def client_performance
clients = Client.created_before(periods.last)
{
total: volunteers.count,
active: active_ids.uniq.size,
new: volunteers.created_between(period_start, period_end).size
all: clients_stats(clients),
zurich: clients_stats(clients.zurich),
not_zurich: clients_stats(clients.not_zurich)
}
end
def clients_stats(clients)
{
created: clients.created_after(periods.first).count,
active_assignment: clients.active.count,
inactive: clients.inactive.count,
total: clients.count,
resigned: clients.resigned_between(*periods).count
}
end
def assignment_performance
assignments = Assignment.created_before(periods.last)
{
all: assignments_stats(assignments),
zurich: assignments_stats(assignments.zurich),
not_zurich: assignments_stats(assignments.not_zurich),
external: assignments_stats(assignments.external),
internal: assignments_stats(assignments.internal)
}
end
def clients(zurich = false)
clients = Client.created_before(period_end)
clients = zurich ? clients.zurich : clients.not_zurich
def assignments_stats(assignments)
hours = Hour.date_between(:meeting_date, *periods).from_assignments(assignments.ids)
feedbacks = Feedback.created_between(*periods).from_assignments(assignments.ids)
trial_feedbacks = TrialFeedback.created_between(*periods).from_assignments(assignments.ids)
{
new: clients.created_between(period_start, period_end).distinct.count,
active: clients.with_active_assignment_between(period_start, period_end).distinct.count,
total: clients.count
all: assignments.count,
created: assignments.created_between(*periods).count,
started: assignments.start_within(*periods).count,
active: assignments.active_between(*periods).count,
ended: assignments.end_within(*periods).count,
probations_ended: assignments.date_between(:probation_period, *periods).count,
performance_appraisal_reviews: assignments.date_between(:performance_appraisal_review, *periods).count,
home_visits: assignments.date_between(:home_visit, *periods).count,
first_instruction_lessons: assignments.date_between(:first_instruction_lesson, *periods).count,
progress_meetings: assignments.date_between(:progress_meeting, *periods).count,
termination_submitted: assignments.termination_submitted_between(*periods).count,
termination_verified: assignments.termination_verified_between(*periods).count,
hour_report_count: hours.count,
hours: hours.sum(:hours) + (hours.sum(:minutes) / 60.0),
feedback_count: feedbacks.count,
trial_feedback_count: trial_feedbacks.count
}
end
def assignments(zurich = false)
assignments = Assignment.created_before(period_end)
assignments = zurich ? assignments.zurich : assignments.not_zurich
assignments = extern ? assignments.external : assignments.internal
def group_offer_performance
group_offers = GroupOffer.created_before(periods.last)
{
ended: assignments.end_within(period_start, period_end).count,
new: assignments.start_within(period_start, period_end).count,
active: assignments.active_between(period_start, period_end).count,
total: assignments.count
all: group_offer_stats(group_offers),
in_departments: group_offer_stats(group_offers.where.not(department_id: nil)),
outside_departments: group_offer_stats(group_offers.where(department_id: nil))
}
end
def group_offers
group_offers = GroupOffer.created_before(period_end)
active = group_offers.map do |group_offer|
group_offer.active_group_assignments_between?(period_start, period_end)
end.grep(true)
ended = group_offers.map do |group_offer|
group_offer.all_group_assignments_ended_within?(period_start, period_end)
end.grep(true)
new_group_offers = group_offers.map do |group_offer|
group_offer.all_group_assignments_started_within?(period_start, period_end)
end.grep(true)
def group_offer_stats(group_offers)
group_assignments = GroupAssignment.created_before(periods.last)
.where(group_offer_id: group_offers.ids)
active_ga = group_assignments.active_between(*periods)
started_ga = group_assignments.start_within(*periods)
ended_ga = group_assignments.end_within(*periods)
created_ga = group_assignments.created_between(*periods)
hours = Hour.from_group_offers(group_offers.ids)
feedbacks = Feedback.created_between(*periods).from_group_offers(group_offers.ids)
{
active: active.size,
new: new_group_offers.size,
total: group_offers.count,
ended: ended.size
all: group_offers.count,
created: group_offers.created_after(periods.first).count,
ended: group_offers.end_within(*periods).count,
termination_verified: group_offers.termination_verified_between(*periods).count,
created_assignments: created_ga.pluck(:group_offer_id).uniq.size,
started_assignments: started_ga.pluck(:group_offer_id).uniq.size,
active_assignments: active_ga.pluck(:group_offer_id).uniq.size,
ended_assignments: ended_ga.pluck(:group_offer_id).uniq.size,
total_assignments: group_assignments.count,
total_created_assignments: created_ga.count,
total_started_assignments: started_ga.count,
total_active_assignments: active_ga.count,
total_ended_assignments: ended_ga.count,
hour_report_count: hours.count,
hours: hours.sum(:hours) + (hours.sum(:minutes) / 60.0),
feedback_count: feedbacks.count
}
end
end
......@@ -11,6 +11,15 @@ class TrialFeedback < ApplicationRecord
validates :body, presence: true
scope :assignment, (-> { where(trial_feedbackable_type: 'Assignment') })
scope :group_offer, (-> { where(trial_feedbackable_type: 'GroupOffer') })
scope :from_assignments, lambda { |assignment_ids|
assignment.where(trial_feedbackable_id: assignment_ids)
}
scope :from_group_offers, lambda { |group_offer_ids|
group_offer.where(trial_feedbackable_id: group_offer_ids)
}
def assignment?
trial_feedbackable_type == 'Assignment'
end
......
......@@ -7,7 +7,7 @@ class Volunteer < ApplicationRecord
include FullBankDetails
before_validation :handle_user_with_external_change, if: :external_changed?
before_save :record_acceptance_changed
before_save :record_acceptance_changed, if: :will_save_change_to_acceptance?
after_update :copy_contact_to_user, if: :user_added?
SINGLE_ACCOMPANIMENTS = [:man, :woman, :family, :kid, :unaccompanied].freeze
......@@ -83,32 +83,37 @@ class Volunteer < ApplicationRecord
scope :with_assignments, (-> { joins(:assignments) })
scope :with_group_assignments, (-> { joins(:group_assignments) })
scope :without_assignment, (-> { left_outer_joins(:assignments).where(assignments: { id: nil }) })
scope :without_group_assignments, lambda {
left_outer_joins(:group_assignments).where(group_assignments: { id: nil })
}
scope :with_active_assignments_between, lambda { |start_date, end_date|
joins(:assignments).merge(Assignment.active_between(start_date, end_date))
}
scope :with_terminated_assignments_between, lambda { |start_date, end_date|
joins(:assignments).merge(Assignment.terminated_between(start_date, end_date))
}
scope :with_active_group_assignments_between, lambda { |start_date, end_date|
joins(:group_assignments).merge(GroupAssignment.active_between(start_date, end_date))
}
scope :with_active_assignments, (-> { joins(:assignments).merge(Assignment.active) })
scope :without_assignment, (-> { left_outer_joins(:assignments).where(assignments: { id: nil }) })
scope :without_group_offer, lambda {
left_outer_joins(:group_offers).where(group_offers: { id: nil })
}
scope :without_active_assignment, lambda {
joins(:assignments).merge(Assignment.ended)
}
scope :not_in_any_group_offer, lambda {
left_joins(:group_offers).where(group_assignments: { volunteer_id: nil })
}
scope :with_active_assignments_between, lambda { |start_date, end_date|
joins(:assignments).merge(Assignment.active_between(start_date, end_date))
}
scope :with_terminated_assignments_between, lambda { |start_date, end_date|
joins(:assignments).merge(Assignment.terminated_between(start_date, end_date))
}
scope :with_active_group_assignments_between, lambda { |start_date, end_date|
joins(:group_assignments).merge(GroupAssignment.active_between(start_date, end_date))
}
scope :external, (-> { where(external: true) })
scope :internal, (-> { where(external: false) })
scope :not_resigned, (-> { where.not(acceptance: :resigned) })
......@@ -152,6 +157,14 @@ class Volunteer < ApplicationRecord
seeking_clients.or(accepted.will_take_more_assignments)
}
scope :resigned_between, lambda { |start_date, end_date|
date_between_inclusion(:resigned_at, start_date, end_date)
}
scope :accpted_between, lambda { |start_date, end_date|
date_between_inclusion(:accepted_at, start_date, end_date)
}
def verify_and_update_state
update(active: active?, activeness_might_end: relevant_period_end_max)
end
......@@ -368,8 +381,7 @@ class Volunteer < ApplicationRecord
end
def record_acceptance_changed
return unless will_save_change_to_acceptance?
self["#{acceptance_change_to_be_saved[1]}_at".to_sym] = Time.zone.now
self["#{acceptance}_at".to_sym] = Time.zone.now
end
def user_deleted?
......
......@@ -7,8 +7,6 @@
.row
.col-xs-12= f.input :period, as: :date_year_range_picker, label: false
.col-xs-12= f.input :extern
.row
.col-xs-12
= f.button :submit
......@@ -12,9 +12,7 @@ nav.navbar.section-navigation
tr
th= t_attr(:created_at)
th= t_attr(:period)
th= t_attr(:scope)
th= t_attr(:extern)
th colspan='3'
th colspan='4'
tbody
- @performance_reports.each do |performance_report|
......@@ -27,9 +25,8 @@ nav.navbar.section-navigation
= l(performance_report.period_start.to_date, format: :default)
= " - "
= l(performance_report.period_end.to_date, format: :default)
td= performance_report.scope
td= t(performance_report.extern)
td = link_to t_action(:show), performance_report
td = link_to 'Excel downloaden', performance_report_path(performance_report, format: :xlsx)
td = link_to t_action(:edit), edit_performance_report_path(performance_report)
td = link_to navigation_glyph(:delete), performance_report, confirm_deleting(performance_report)
......
wb = xlsx_package.workbook
col_header = col_header = wb.styles.add_style(
bg_color: 'FFDFDEDF',
b: true,
alignment: { horizontal: :center, vertical: :center },
border: { color: '00', edges: [:bottom], style: :thin})
number_cell_style = wb.styles.add_style(alignment: { horizontal: :center }, width: :auto_fit)
wb.add_worksheet(name: 'Freiwillige') do |sheet|
volunteers = @report_content['volunteers']
column_order = ['zurich', 'not_zurich', 'internal', 'external', 'all']
header_row = column_order.map do |category_key|
t(".volunteers.categories.#{category_key}")
end.unshift('')
sheet.add_row header_row, style: col_header
cell_types = Array.new(column_order.size).map { :integer }.unshift(:string)
cell_styles = Array.new(column_order.size).map { number_cell_style }.unshift(nil)
[
:created, :inactive, :resigned, :total, :only_assignment_active, :active_group_assignment,
:only_group_active, :active_both, :active_assignment, :active_total, :assignment_hour_records,
:assignment_hours, :group_offer_hour_records, :group_offer_hours, :total_hour_records,
:total_hours, :assignment_feedbacks, :group_offer_feedbacks, :total_feedbacks,
:assignment_trial_feedbacks, :group_offer_trial_feedbacks, :total_trial_feedbacks
].each do |row_key|
row = [t(".volunteers.values.#{row_key}")] +
column_order.map { |col| volunteers[col][row_key.to_s] }
sheet.add_row row, types: cell_types, style: cell_styles
end
end
wb.add_worksheet(name: 'Klienten') do |sheet|
clients = @report_content['clients']
column_order = ['zurich', 'not_zurich', 'all']
header_row = column_order.map do |category_key|
t(".clients.categories.#{category_key}")
end.unshift('')
sheet.add_row header_row, style: col_header
cell_types = Array.new(column_order.size).map { :integer }.unshift(:string)
cell_styles = Array.new(column_order.size).map { number_cell_style }.unshift(nil)
[:created, :inactive, :resigned, :total, :active_assignment].each do |row_key|
row = [t(".clients.values.#{row_key}")] +
column_order.map { |col| clients[col][row_key.to_s] }
sheet.add_row row, types: cell_types, style: cell_styles
end
end
wb.add_worksheet(name: 'Begleitungen') do |sheet|
assignments = @report_content['assignments']
column_order = ['zurich', 'not_zurich', 'internal', 'external', 'all']
header_row = column_order.map do |category_key|
t(".assignments.categories.#{category_key}")
end.unshift('')
sheet.add_row header_row, style: col_header
cell_types = Array.new(column_order.size).map { :integer }.unshift(:string)
cell_styles = Array.new(column_order.size).map { number_cell_style }.unshift(nil)
[
:created, :started, :active, :ended, :all, :hour_report_count, :hours, :feedback_count,
:first_instruction_lessons, :probations_ended, :trial_feedback_count,
:performance_appraisal_reviews, :home_visits, :progress_meetings, :termination_submitted,
:termination_verified
].each do |row_key|
row = [t(".assignments.values.#{row_key}")] +
column_order.map { |col| assignments[col][row_key.to_s] }
sheet.add_row row, types: cell_types, style: cell_styles
end
end
wb.add_worksheet(name: 'Gruppenangebote') do |sheet|
group_offers = @report_content['group_offers']
column_order = ['in_departments', 'outside_departments', 'all']
header_row = column_order.map do |category_key|
t(".group_offers.categories.#{category_key}")
end.unshift('')
sheet.add_row header_row, style: col_header
cell_types = Array.new(column_order.size).map { :integer }.unshift(:string)
cell_styles = Array.new(column_order.size).map { number_cell_style }.unshift(nil)
[
:created, :ended, :all, :created_assignments, :started_assignments, :ended_assignments,
:active_assignments, :total_created_assignments, :total_started_assignments,
:total_active_assignments, :total_ended_assignments, :total_assignments, :hour_report_count,
:hours, :feedback_count
].each do |row_key|
row = [t(".group_offers.values.#{row_key}")] +
column_order.map { |col| group_offers[col][row_key.to_s] }
sheet.add_row row, types: cell_types, style: cell_styles
end
end
This diff is collapsed.
This diff is collapsed.
class ClientAcceptanceChangeFields < ActiveRecord::Migration[5.1]
def change
change_table :clients do |t|
t.remove :resigned_on
t.datetime :resigned_at
t.datetime :accepted_at
t.datetime :rejected_at
end
end
end
class DropExternalFromPerformanceReports < ActiveRecord::Migration[5.1]
def change
change_table :performance_reports do |t|
t.remove :extern
t.remove :scope
end
end
end
......@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20180202110148) do
ActiveRecord::Schema.define(version: 20180205203826) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
......@@ -166,8 +166,10 @@ ActiveRecord::Schema.define(version: 20180202110148) do
t.integer "acceptance", default: 0
t.integer "cost_unit"
t.bigint "involved_authority_id"
t.date "resigned_on"
t.bigint "resigned_by_id"
t.datetime "resigned_at"
t.datetime "accepted_at"
t.datetime "rejected_at"
t.index ["deleted_at"], name: "index_clients_on_deleted_at"
t.index ["involved_authority_id"], name: "index_clients_on_involved_authority_id"
t.index ["resigned_by_id"], name: "index_clients_on_resigned_by_id"
......@@ -435,8 +437,6 @@ ActiveRecord::Schema.define(version: 20180202110148) do
t.integer "year"
t.bigint "user_id"
t.jsonb "report_content"
t.boolean "extern", default: false
t.string "scope"
t.string "title"
t.text "comment"
t.datetime "deleted_at"
......
......@@ -108,88 +108,119 @@ if EmailTemplate.count < 1
end
puts_model_counts('After EmailTemplates created', User, EmailTemplate)
def assignment_generator(creator, create_day, start_date = nil, end_date = nil, terminated_at: nil, volunteer: nil)
volunteer ||= FactoryBot.create(:volunteer_seed_with_user, acceptance: 'accepted')
volunteer.update(created_at: create_day, updated_at: create_day + 1)
client = FactoryBot.create(:client, acceptance: 'accepted', user: creator)
client.update(created_at: create_day - 5)
start_date ||= Faker::Date.between(create_day, create_day + 50)
assignment = FactoryBot.create(:assignment, volunteer: volunteer, period_start: start_date,
period_end: end_date, creator: creator,
client: FactoryBot.create(:client, acceptance: 'accepted', user: creator))