-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #588 from ChicagoWorldcon/development
2.0.0-rc1
- Loading branch information
Showing
37 changed files
with
809 additions
and
114 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
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,11 @@ | ||
class PublicationDatesController < ResourceController | ||
SERIALIZER_CLASS = 'PublicationDateSerializer'.freeze | ||
POLICY_CLASS = 'PublicationDatePolicy'.freeze | ||
POLICY_SCOPE_CLASS = 'PublicationDatePolicy::Scope'.freeze | ||
DEFAULT_SORTBY = 'timestamp' | ||
DEFAULT_ORDER = 'desc'.freeze | ||
|
||
def paginate | ||
false | ||
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
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,52 @@ | ||
class Reports::ProgramOpsReportsController < ApplicationController | ||
around_action :set_timezone | ||
|
||
def back_of_badge | ||
authorize SessionAssignment, policy_class: Reports::ProgramOpsReportPolicy | ||
|
||
assignments = PublishedSessionAssignment | ||
.includes(:person, :session_assignment_role_type, :published_session) | ||
.order("people.published_name, published_sessions.start_time asc") | ||
|
||
|
||
workbook = FastExcel.open #(constant_memory: true) | ||
worksheet = workbook.add_worksheet("Back of Badge") | ||
date_time_style = workbook.number_format("d mmm yyyy h:mm") | ||
|
||
worksheet.append_row([]) # For the header | ||
|
||
group_assignments = assignments.group_by {|a| a.person} | ||
max_sessions = 0 | ||
group_assignments.each do |person, grouped| | ||
row = [ | ||
person.published_name | ||
] | ||
styles = [nil] | ||
|
||
grouped.each do |assignment| | ||
row.concat [ | ||
assignment.session.title, | ||
assignment.session.start_time ? FastExcel.date_num(assignment.session.start_time, assignment.session.start_time.in_time_zone.utc_offset) : nil, | ||
assignment.session.duration, | ||
assignment.session.room&.name, | ||
] | ||
styles.concat [ | ||
nil, date_time_style, nil, nil | ||
] | ||
end | ||
max_sessions = grouped.size if grouped.size > max_sessions | ||
|
||
worksheet.append_row(row, styles) | ||
end | ||
|
||
header = ['Published Name'] | ||
(0..max_sessions).each do |n| | ||
header.concat ["Title #{n+1}", "Start Time #{n+1}", "Duration #{n+1}", "Room #{n+1}"] | ||
end | ||
worksheet.write_row(0, header) | ||
|
||
send_data workbook.read_string, | ||
filename: "BackOfBadge-#{Time.now.strftime('%m-%d-%Y')}.xlsx", | ||
disposition: 'attachment' | ||
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,207 @@ | ||
class Reports::ScheduleReportsController < ApplicationController | ||
around_action :set_timezone | ||
|
||
def schedule_diff | ||
authorize Person, policy_class: Reports::ScheduleReportPolicy | ||
|
||
# TODO: base the from and to on the publish ids and this will be ok as a get | ||
pd_from = PublicationDate.find params[:from] if params[:from] | ||
|
||
from = pd_from.timestamp if pd_from | ||
from ||= PublicationDate.order('created_at desc').first&.timestamp | ||
from ||= Time.now - 2.year # TODO: for testing | ||
|
||
pd_to = PublicationDate.find params[:to] if params[:to] | ||
to = pd_to.timestamp if pd_to | ||
|
||
# changes = ChangeService.published_changes(from: from, to: to) | ||
changes = if to | ||
ChangeService.published_changes(from: from, to: to) | ||
else | ||
ChangeService.session_changes(from: from) | ||
end | ||
|
||
to ||= Time.now | ||
workbook = FastExcel.open(constant_memory: true) | ||
date_time_style = workbook.number_format("d mmm yyyy h:mm") | ||
|
||
session_time_changed = workbook.add_worksheet("Session Time Changed") | ||
session_room_changed = workbook.add_worksheet("Session Room Changed") | ||
session_title_changed = workbook.add_worksheet("Session Title Changed") | ||
session_description_changed = workbook.add_worksheet("Session Description Changed") | ||
session_added = workbook.add_worksheet("Sessions Add") | ||
session_removed = workbook.add_worksheet("Sessions Removed") | ||
|
||
participants_fully_dropped = workbook.add_worksheet("Participants Dropped") | ||
participants_add_drop = workbook.add_worksheet("Participants Add Drop") | ||
|
||
tab_headers(session_time_changed, session_room_changed, session_title_changed, session_description_changed, session_added, session_removed, participants_add_drop, participants_fully_dropped) | ||
|
||
# Rails.logger.debug "******** CHANGES: #{changes[:sessions]}" | ||
|
||
changes[:sessions].values.sort{|a,b| (a[:object] ? a[:object].title : '') <=> (b[:object] ? b[:object].title : '')}.each do |change| | ||
# Rails.logger.debug "******** CHANGE: #{change}" | ||
next unless change[:object] | ||
|
||
if change[:changes]['room_id'] || change[:changes]['start_time'] | ||
if change[:changes]['room_id'] && change[:changes]['start_time'] && | ||
((!change[:changes]['room_id'][0] && change[:changes]['room_id'][1]) || | ||
(!change[:changes]['start_time'][0] && change[:changes]['start_time'][1])) | ||
session_added_row(session_added, change, date_time_style) | ||
else | ||
if (change[:changes]['room_id'] && !change[:changes]['room_id'][1]) || (change[:changes]['start_time'] && !change[:changes]['start_time'][1])|| change[:event] == 'destroy' | ||
session_removed_row(session_removed, change) | ||
else | ||
if change[:changes]['room_id'] | ||
session_room_change_row(session_room_changed, change) | ||
end | ||
if change[:changes]['start_time'] | ||
session_time_change_row(session_time_changed, change, date_time_style) | ||
end | ||
end | ||
end | ||
end | ||
|
||
if change[:changes]['title'] | ||
session_title_change_row(session_title_changed, change) | ||
end | ||
if change[:changes]['description'] | ||
session_description_change_row(session_description_changed, change) | ||
end | ||
end | ||
|
||
moderator = SessionAssignmentRoleType.find_by(name: 'Moderator') | ||
participant = SessionAssignmentRoleType.find_by(name: 'Participant') | ||
roles = [moderator.id, participant.id] | ||
# Rails.logger.debug "******** ROLES #{roles}" | ||
|
||
# TODO: sort .... ??? how | ||
fully_dropped = [] | ||
changes[:assignments].each do |id, change| | ||
next unless change[:object] | ||
|
||
# Participants add/drop | ||
if change[:changes]['session_assignment_role_type_id'] | ||
session = change[:object].session if change[:object].session | ||
session ||= Session.find change[:object].session_id | ||
if (roles.include?(change[:changes]['session_assignment_role_type_id'][1])) | ||
participants_add_drop.append_row( | ||
[ | ||
session.title, | ||
'', | ||
change[:object].person.published_name | ||
] | ||
) | ||
elsif (roles.include?(change[:changes]['session_assignment_role_type_id'][0])) | ||
participants_add_drop.append_row( | ||
[ | ||
session.title, | ||
change[:object].person.published_name, | ||
] | ||
) | ||
if change[:object].person.sessions.scheduled.count == 0 | ||
fully_dropped.append [change[:object].person.published_name] | ||
end | ||
end | ||
end | ||
end | ||
|
||
fully_dropped.uniq.each do |name| | ||
participants_fully_dropped.append_row(name) | ||
end | ||
|
||
send_data workbook.read_string, | ||
filename: "ScheduleDiff-#{from.strftime('%m-%d-%Y_%H_%M')}_to_#{to.strftime('%m-%d-%Y_%H_%M')}.xlsx", | ||
disposition: 'attachment' | ||
end | ||
|
||
def tab_headers(session_time_changed, session_room_changed, session_title_changed, session_description_changed, session_added, session_removed, participants_add_drop, participants_fully_dropped) | ||
session_time_changed.append_row(['Session Title','Original Start Time', 'New Start Time']) | ||
session_room_changed.append_row(['Session Title','Original Room', 'New Room']) | ||
session_title_changed.append_row(['Original Session Title', 'New Session Title']) | ||
session_description_changed.append_row(['Session Title','Original Description', 'New Description']) | ||
session_added.append_row(['Session Title', 'Session Description', 'Format', 'Areas', 'Start Time', 'Room', 'Moderators', 'Participants']) | ||
session_removed.append_row(['Session Title']) | ||
|
||
participants_add_drop.append_row(['Session Title', 'Participant Dropped', 'Participant Added']) | ||
participants_fully_dropped.append_row(['Participant Dropped']) | ||
end | ||
|
||
def session_description_change_row(sheet, change) | ||
sheet.append_row( | ||
[ | ||
change[:object].title, | ||
change[:changes]['description'][0], | ||
change[:changes]['description'][1] | ||
] | ||
) | ||
end | ||
|
||
def session_title_change_row(sheet, change) | ||
sheet.append_row( | ||
[ | ||
change[:changes]['title'][0], | ||
change[:changes]['title'][1] | ||
] | ||
) | ||
end | ||
|
||
def session_room_change_row(sheet, change) | ||
orig_room = Room.find change[:changes]['room_id'][0] if change[:changes]['room_id'][0] | ||
new_room = Room.find change[:changes]['room_id'][1] if change[:changes]['room_id'][1] | ||
sheet.append_row( | ||
[ | ||
change[:object].title, | ||
orig_room&.name, | ||
new_room&.name | ||
] | ||
) | ||
end | ||
|
||
def session_removed_row(sheet, change) | ||
# TODO: if it is a destroy .... | ||
sheet.append_row( | ||
[ | ||
change[:object].title | ||
] | ||
) | ||
end | ||
|
||
def session_time_change_row(sheet, change, date_time_style) | ||
orig_time = Time.parse(change[:changes]['start_time'][0]) if change[:changes]['start_time'][0] | ||
new_time = Time.parse(change[:changes]['start_time'][1]) if change[:changes]['start_time'][1] | ||
# Rails.logger.debug "********* #{change[:changes]['start_time'][1]} => #{new_time.class} #{new_time.strftime("%H")}" | ||
sheet.append_row( | ||
[ | ||
change[:object].title, | ||
orig_time ? FastExcel.date_num(orig_time, orig_time.in_time_zone.utc_offset) : nil, | ||
new_time ? FastExcel.date_num(new_time, new_time.in_time_zone.utc_offset) : nil | ||
], | ||
[ | ||
nil, date_time_style, date_time_style | ||
] | ||
) | ||
end | ||
|
||
# Generate a row for sessions added | ||
def session_added_row(sheet, change, date_time_style) | ||
moderator = SessionAssignmentRoleType.find_by(name: 'Moderator') | ||
participant = SessionAssignmentRoleType.find_by(name: 'Participant') | ||
|
||
sheet.append_row( | ||
[ | ||
change[:object].title, | ||
change[:object].description, | ||
change[:object].format&.name, | ||
change[:object].areas.collect(&:name).join("; "), | ||
FastExcel.date_num(change[:object].start_time, change[:object].start_time.in_time_zone.utc_offset), | ||
change[:object].room&.name, | ||
change[:object].participant_assignments.where("session_assignment_role_type_id = ?", moderator).collect{|a| a.person.published_name}.join("; "), | ||
change[:object].participant_assignments.where("session_assignment_role_type_id = ?", participant).collect{|a| a.person.published_name}.join("; ") | ||
], | ||
[ | ||
nil, nil, nil, nil, date_time_style, nil, nil, nil | ||
] | ||
) | ||
end | ||
end |
Oops, something went wrong.