From 42b4807e070e83f0cd705457105a2a13d337ef05 Mon Sep 17 00:00:00 2001 From: ralphlevan Date: Sat, 16 Jul 2022 15:38:57 -0400 Subject: [PATCH 01/19] PLAN-585 Added human strings for con state values and use them to format the table values --- app/javascript/constants/strings.js | 12 ++++++++++++ app/javascript/people/people.js | 17 ++++++----------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/app/javascript/constants/strings.js b/app/javascript/constants/strings.js index d6585b02c..7aa9bbb75 100644 --- a/app/javascript/constants/strings.js +++ b/app/javascript/constants/strings.js @@ -241,6 +241,18 @@ module.exports = { }, PERSON_SAVE_SUCCESS: "Profile record saved successfully", PERSON_NEVER_LOGGED_IN: "Never logged in", + PERSON_CON_STATE: { + not_set: "Not Set", + applied: "Applied", + vetted: "Vetted", + wait_list: "Wait List", + invite_pending: "Invite Pending", + invited: "Invited", + probable: "Probable", + accepted: "Accepted", + declined: "Declined", + rejected: "Rejected" + }, SURVEY_REDIRECT: "Unfortunately due to the browser refreshing we have lost any answers you filled in. Please fill the survey out again.", SURVEY_PUBLIC_NO_EDIT: "You cannot edit a published survey. Close the survey to enable editing.", diff --git a/app/javascript/people/people.js b/app/javascript/people/people.js index f49414944..3804753c9 100644 --- a/app/javascript/people/people.js +++ b/app/javascript/people/people.js @@ -1,3 +1,5 @@ +import {PERSON_CON_STATE, SESSION_STATUS} from "@/constants/strings"; + export const people_columns = [ { key: 'published_name', @@ -32,19 +34,12 @@ export const people_columns = [ search_key: 'con_state', label: 'Status', type: "select", + formatter: (value) => PERSON_CON_STATE[value] || value, // TODO: needs to be driven by settings enums choices: [ - {label: "not_set", value: "not_set"}, - {label: "applied", value: "applied"}, - {label: "vetted", value: "vetted"}, - {label: "wait_list", value: "wait_list"}, - {label: "invite_pending", value: "invite_pending"}, - {label: "invited", value: "invited"}, - {label: "probable", value: "probable"}, - {label: "accepted", value: "accepted"}, - {label: "declined", value: "declined"}, - {label: "rejected", value: "rejected"} - ], + "not_set", "applied", "vetted", "wait_list", "invite_pending", + "invited", "probable", "accepted", "declined", "rejected" + ].map(value => ({label: PERSON_CON_STATE[value], value})), operators: ["=", "!="], sortable: false }, From 9cb4f696236a951b79dbce134a9788ffc8a9e8db Mon Sep 17 00:00:00 2001 From: Henry Date: Wed, 20 Jul 2022 09:59:30 -0400 Subject: [PATCH 02/19] Coclar WIP --- app/controllers/schedule_controller.rb | 42 ++++++++++++++ app/serializers/conclar/session_serializer.rb | 56 +++++++++++++++++++ app/services/reports_service.rb | 35 +++++------- config/routes.rb | 4 +- 4 files changed, 114 insertions(+), 23 deletions(-) create mode 100644 app/controllers/schedule_controller.rb create mode 100644 app/serializers/conclar/session_serializer.rb diff --git a/app/controllers/schedule_controller.rb b/app/controllers/schedule_controller.rb new file mode 100644 index 000000000..a68247632 --- /dev/null +++ b/app/controllers/schedule_controller.rb @@ -0,0 +1,42 @@ +# Produce a schedule suitable for Conclar +class ScheduleController < ApplicationController + skip_before_action :check_up, :authenticate_person!, only: [:index, :participants] + + def index + # TODO: we really need to use published sessions, this is fine for testing for now + sessions = ReportsService.scheduled_sessions + + render plain: "var program = " + ActiveModel::Serializer::CollectionSerializer.new( + sessions, + serializer: Conclar::SessionSerializer + ).to_json + end + + def participants + # All participants on the schedule ... + # var people = [ + # { + # "id": "4567", + # "name": [ "Friend Andhis Jr." ], + # "sortname" : "Andhis Jr., Friend", + # "tags": [], + # "prog": [ "1234", "614", "801" ], + # "links": [], + # "bio": "Prior art for Adams's satirical point – that humans attach such importance to their automobiles that a visiting extraterrestrial might reasonably mistake them for the planet's dominant life form – can be found in a widely reprinted article from The Rockefeller Institute Review titled Life on Earth (by a Martian) by Paul Weiss. The idea was also expounded by Carl Sagan, though this may have postdated Adams's creation of the character of Ford. The 1967 Oscar-nominated animated film What on Earth! from the National Film Board of Canada is also based on this premise." + # }, + # { + # "id": "1234", + # "name": [ "Galahad", "", "Sir" ], + # "sortname": "Sir Galahad", + # "tags": [ "GoH" ], + # "prog": [ "416" ], + # "links": { + # "img": "/images/galahad.jpg", + # "photo": "/images/galahad.jpg", + # "img_256_url": "/images/galahad.jpg", + # "url": "http://en.wikipedia.org/wiki/Galahad" + # }, + # "bio": "Sir Galahad (/ˈɡæləhæd/; Middle Welsh: Gwalchavad, sometimes referred to as Galeas /ɡəˈliːəs/ or Galath /ˈɡæləθ/), in Arthurian legend, is a knight of King Arthur's Round Table and one of the three achievers of the Holy Grail." + # }, + end +end diff --git a/app/serializers/conclar/session_serializer.rb b/app/serializers/conclar/session_serializer.rb new file mode 100644 index 000000000..093a01fd0 --- /dev/null +++ b/app/serializers/conclar/session_serializer.rb @@ -0,0 +1,56 @@ +class Conclar::SessionSerializer < ActiveModel::Serializer + attributes :id, :title, :start_time + + attribute :desc do + object.description + end + + # TODO: change for when we do have tags + attribute :tags do + res = [] + + # TODO: optimize + res.concat object.areas.collect(&:name) + + res.concat [object.age_restriction.name] if object.age_restriction + res.concat [object.environment] if object.environment != 'unknown' + + if object.minors_participation && object.minors_participation.class == Array + res.concat object.minors_participation + end + + res + end + + attribute :mins do + object.duration + end + + attribute :loc do + # [ "Some Room", "Some Area" ], + if object.room + [object.room.name, object.room.venue.name] + else + [] + end + end + + attribute :people do + moderator = SessionAssignmentRoleType.find_by(name: 'Moderator') + invisible = SessionAssignmentRoleType.find_by(name: 'Invisible') + parts = [] + object.participant_assignments.each do |assignment| + next if assignment.session_assignment_role_type_id == invisible.id + + p = { + id: assignment.person.id, + name: assignment.person.published_name + # role: nil + } + p['role'] = 'moderator' if assignment.session_assignment_role_type_id == moderator.id + parts << p + end + + parts + end +end diff --git a/app/services/reports_service.rb b/app/services/reports_service.rb index 36f63b0c7..bc47e54a2 100644 --- a/app/services/reports_service.rb +++ b/app/services/reports_service.rb @@ -1,27 +1,5 @@ module ReportsService - def self.all_sessions - sessions_table = Session.arel_table - subquery = Session.area_list.as('areas_list') - - joins = [ - sessions_table.create_join( - subquery, - sessions_table.create_on( - subquery[:session_id].eq(sessions_table[:id]) - ), - Arel::Nodes::OuterJoin - ) - ] - - Session.select( - ::Session.arel_table[Arel.star], - 'areas_list.area_list' - ) - .joins(joins) - .order('title') - end - def self.all_conflicts(ignored: false) conflicts_table = ::Conflicts::SessionConflict.arel_table subquery = Session.area_list.as('areas_list') @@ -95,6 +73,19 @@ def self.scheduled_session_no_people # .order(:start_time) end + # Get all the schedule sessions + def self.scheduled_sessions + Session.select( + ::Session.arel_table[Arel.star], + 'areas_list.area_list' + ) + .includes(:format, :room, {participant_assignments: :person}) + .joins(self.area_subquery) + .where("start_time is not null and room_id is not null") + .where("status != 'dropped' and status != 'draft'") + .order(:start_time) + end + def self.sessions_with_no_moderator sched_table = PersonSchedule.arel_table diff --git a/config/routes.rb b/config/routes.rb index 86e778f64..e6a3cab4d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -20,6 +20,8 @@ get '/settings', to: 'settings#index' + get '/conclar/schedule', to: 'schedule#index' + # REST based resources get 'person/session/me', to: 'people#me' get 'person/me', to: 'people#me' @@ -62,7 +64,7 @@ get 'report/session_reports/invited_accepted_not_scheduled', to: 'reports/session_reports#invited_accepted_not_scheduled' get 'report/session_reports/session_with_no_moderator', to: 'reports/session_reports#session_with_no_moderator' get 'report/session_reports/assigned_sessions_not_scheduled', to: 'reports/session_reports#assigned_sessions_not_scheduled' - get 'report/session_reports/session_copy_edit_status', to: 'reports/session_reports#session_copy_edit_status' + get 'report/session_reports/session_copy_edit_status', to: 'reports/session_reports#session_copy_edit_status' get 'report/session_reports/scheduled_session_no_people', to: 'reports/session_reports#scheduled_session_no_people' get 'report/session_reports/non_accepted_on_schedule', to: 'reports/session_reports#non_accepted_on_schedule' get 'report/session_reports/participants_over_session_limits', to: 'reports/session_reports#participants_over_session_limits' From c3f9b413b8ef74f062406001adb22e0c8c9bd3b6 Mon Sep 17 00:00:00 2001 From: Henry Date: Wed, 20 Jul 2022 10:28:19 -0400 Subject: [PATCH 03/19] conclar WIP --- app/controllers/schedule_controller.rb | 31 ++--------- .../conclar/participant_serializer.rb | 55 +++++++++++++++++++ app/services/reports_service.rb | 17 +++++- config/routes.rb | 1 + 4 files changed, 78 insertions(+), 26 deletions(-) create mode 100644 app/serializers/conclar/participant_serializer.rb diff --git a/app/controllers/schedule_controller.rb b/app/controllers/schedule_controller.rb index a68247632..a9da386fc 100644 --- a/app/controllers/schedule_controller.rb +++ b/app/controllers/schedule_controller.rb @@ -13,30 +13,11 @@ def index end def participants - # All participants on the schedule ... - # var people = [ - # { - # "id": "4567", - # "name": [ "Friend Andhis Jr." ], - # "sortname" : "Andhis Jr., Friend", - # "tags": [], - # "prog": [ "1234", "614", "801" ], - # "links": [], - # "bio": "Prior art for Adams's satirical point – that humans attach such importance to their automobiles that a visiting extraterrestrial might reasonably mistake them for the planet's dominant life form – can be found in a widely reprinted article from The Rockefeller Institute Review titled Life on Earth (by a Martian) by Paul Weiss. The idea was also expounded by Carl Sagan, though this may have postdated Adams's creation of the character of Ford. The 1967 Oscar-nominated animated film What on Earth! from the National Film Board of Canada is also based on this premise." - # }, - # { - # "id": "1234", - # "name": [ "Galahad", "", "Sir" ], - # "sortname": "Sir Galahad", - # "tags": [ "GoH" ], - # "prog": [ "416" ], - # "links": { - # "img": "/images/galahad.jpg", - # "photo": "/images/galahad.jpg", - # "img_256_url": "/images/galahad.jpg", - # "url": "http://en.wikipedia.org/wiki/Galahad" - # }, - # "bio": "Sir Galahad (/ˈɡæləhæd/; Middle Welsh: Gwalchavad, sometimes referred to as Galeas /ɡəˈliːəs/ or Galath /ˈɡæləθ/), in Arthurian legend, is a knight of King Arthur's Round Table and one of the three achievers of the Holy Grail." - # }, + participants = ReportsService.scheduled_people + + render json: ActiveModel::Serializer::CollectionSerializer.new( + participants, + serializer: Conclar::ParticipantSerializer + ).to_json end end diff --git a/app/serializers/conclar/participant_serializer.rb b/app/serializers/conclar/participant_serializer.rb new file mode 100644 index 000000000..85492d0bb --- /dev/null +++ b/app/serializers/conclar/participant_serializer.rb @@ -0,0 +1,55 @@ +class Conclar::ParticipantSerializer < ActiveModel::Serializer + attributes :id, :bio + + attribute :name do + object.published_name + end + + attribute :sortname do + object.published_name_sort_by + end + + attribute :prog do + res = [] + moderator = SessionAssignmentRoleType.find_by(name: 'Moderator') + participant = SessionAssignmentRoleType.find_by(name: 'Participant') + + object.session_assignments.each do |assignment| + next if assignment.session_assignment_role_type_id != moderator.id and assignment.session_assignment_role_type_id != participant.id + + res << assignment.session_id + end + + res + end + + # links ???? + # what about social media URLs? + # tags - not supported yet +end + +# All participants on the schedule ... +# var people = [ +# { +# "id": "4567", +# "name": [ "Friend Andhis Jr." ], +# "sortname" : "Andhis Jr., Friend", +# "tags": [], +# "prog": [ "1234", "614", "801" ], +# "links": [], +# "bio": "Prior art for Adams's satirical point – that humans attach such importance to their automobiles that a visiting extraterrestrial might reasonably mistake them for the planet's dominant life form – can be found in a widely reprinted article from The Rockefeller Institute Review titled Life on Earth (by a Martian) by Paul Weiss. The idea was also expounded by Carl Sagan, though this may have postdated Adams's creation of the character of Ford. The 1967 Oscar-nominated animated film What on Earth! from the National Film Board of Canada is also based on this premise." +# }, +# { +# "id": "1234", +# "name": [ "Galahad", "", "Sir" ], +# "sortname": "Sir Galahad", +# "tags": [ "GoH" ], +# "prog": [ "416" ], +# "links": { +# "img": "/images/galahad.jpg", +# "photo": "/images/galahad.jpg", +# "img_256_url": "/images/galahad.jpg", +# "url": "http://en.wikipedia.org/wiki/Galahad" +# }, +# "bio": "Sir Galahad (/ˈɡæləhæd/; Middle Welsh: Gwalchavad, sometimes referred to as Galeas /ɡəˈliːəs/ or Galath /ˈɡæləθ/), in Arthurian legend, is a knight of King Arthur's Round Table and one of the three achievers of the Holy Grail." +# }, diff --git a/app/services/reports_service.rb b/app/services/reports_service.rb index bc47e54a2..5a85ba44b 100644 --- a/app/services/reports_service.rb +++ b/app/services/reports_service.rb @@ -73,7 +73,7 @@ def self.scheduled_session_no_people # .order(:start_time) end - # Get all the schedule sessions + # Get all the schedule sessions def self.scheduled_sessions Session.select( ::Session.arel_table[Arel.star], @@ -86,6 +86,21 @@ def self.scheduled_sessions .order(:start_time) end + def self.scheduled_people + moderator = SessionAssignmentRoleType.find_by(name: 'Moderator') + participant = SessionAssignmentRoleType.find_by(name: 'Participant') + + people = Person.includes( + {session_assignments: [:session, :session_assignment_role_type]} + ).references( + {session_assignments: :session} + ) + .where("session_assignments.session_assignment_role_type_id in (?)", [moderator.id, participant.id]) + .where("sessions.start_time is not null and sessions.room_id is not null") + .where("sessions.status != 'dropped' and sessions.status != 'draft'") + .where("people.con_state not in (?)", ['declined', 'rejected']) #.distinct + .order("people.published_name") + end def self.sessions_with_no_moderator sched_table = PersonSchedule.arel_table diff --git a/config/routes.rb b/config/routes.rb index e6a3cab4d..429f1e3f1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -21,6 +21,7 @@ get '/settings', to: 'settings#index' get '/conclar/schedule', to: 'schedule#index' + get '/conclar/participants', to: 'schedule#participants' # REST based resources get 'person/session/me', to: 'people#me' From 065f0fa60cf13f66acc6440a160be10f474cdd11 Mon Sep 17 00:00:00 2001 From: Henry Date: Wed, 20 Jul 2022 10:29:46 -0400 Subject: [PATCH 04/19] conclar WIP --- app/controllers/schedule_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/schedule_controller.rb b/app/controllers/schedule_controller.rb index a9da386fc..0f994869c 100644 --- a/app/controllers/schedule_controller.rb +++ b/app/controllers/schedule_controller.rb @@ -15,7 +15,7 @@ def index def participants participants = ReportsService.scheduled_people - render json: ActiveModel::Serializer::CollectionSerializer.new( + render plain: "var people = " + ActiveModel::Serializer::CollectionSerializer.new( participants, serializer: Conclar::ParticipantSerializer ).to_json From a767420bb5842cde146d8cab2a7b7248ede588f5 Mon Sep 17 00:00:00 2001 From: Henry Date: Wed, 20 Jul 2022 11:20:25 -0400 Subject: [PATCH 05/19] use datetime as attribute name --- app/serializers/conclar/session_serializer.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/serializers/conclar/session_serializer.rb b/app/serializers/conclar/session_serializer.rb index 093a01fd0..5189ff8b9 100644 --- a/app/serializers/conclar/session_serializer.rb +++ b/app/serializers/conclar/session_serializer.rb @@ -1,10 +1,14 @@ class Conclar::SessionSerializer < ActiveModel::Serializer - attributes :id, :title, :start_time + attributes :id, :title attribute :desc do object.description end + attribute :datetime do + object.start_time + end + # TODO: change for when we do have tags attribute :tags do res = [] From 05ebead26ce45d7f3b6eca5cd0fc0803a351c33b Mon Sep 17 00:00:00 2001 From: Henry Date: Wed, 20 Jul 2022 14:59:44 -0400 Subject: [PATCH 06/19] changing to just json instead of var = --- app/controllers/schedule_controller.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/controllers/schedule_controller.rb b/app/controllers/schedule_controller.rb index 0f994869c..4a91c4843 100644 --- a/app/controllers/schedule_controller.rb +++ b/app/controllers/schedule_controller.rb @@ -3,21 +3,22 @@ class ScheduleController < ApplicationController skip_before_action :check_up, :authenticate_person!, only: [:index, :participants] def index - # TODO: we really need to use published sessions, this is fine for testing for now sessions = ReportsService.scheduled_sessions - render plain: "var program = " + ActiveModel::Serializer::CollectionSerializer.new( + render json: ActiveModel::Serializer::CollectionSerializer.new( sessions, serializer: Conclar::SessionSerializer - ).to_json + ), + content_type: 'application/json' end def participants participants = ReportsService.scheduled_people - render plain: "var people = " + ActiveModel::Serializer::CollectionSerializer.new( + render ActiveModel::Serializer::CollectionSerializer.new( participants, serializer: Conclar::ParticipantSerializer - ).to_json + ), + content_type: 'application/json' end end From 9b4519e0d60737c7e6ca460410d960b9b6ea3dad Mon Sep 17 00:00:00 2001 From: Henry Date: Wed, 20 Jul 2022 16:53:11 -0400 Subject: [PATCH 07/19] if the request is patch then it may not have time and room in the params --- app/controllers/sessions_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index ee162f40f..a586dc93c 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -143,7 +143,8 @@ def before_update # if time or room have changed removed ignored conflicts p = _permitted_params(model: object_name, instance: @object) if (@object.start_time || @object.room_id) - if p[:start_time] != @object.start_time || p[:room_id] != @object.room_id + if (p.has_key?(:start_time) && p[:start_time] != @object.start_time) || + (p.has_key?(:room_id) && p[:room_id] != @object.room_id) # so we remove any ignore conflicts for this session cids = @object.ignored_session_conflicts.pluck(:conflict_id) cids += @object.ignored_conflict_sessions.pluck(:conflict_id) From b2dace8f0c6b12e21b49b286601ff66859953ee4 Mon Sep 17 00:00:00 2001 From: Henry Date: Thu, 21 Jul 2022 12:54:23 -0400 Subject: [PATCH 08/19] adjust output --- app/controllers/schedule_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/schedule_controller.rb b/app/controllers/schedule_controller.rb index 4a91c4843..02d7fd031 100644 --- a/app/controllers/schedule_controller.rb +++ b/app/controllers/schedule_controller.rb @@ -15,7 +15,7 @@ def index def participants participants = ReportsService.scheduled_people - render ActiveModel::Serializer::CollectionSerializer.new( + render json: ActiveModel::Serializer::CollectionSerializer.new( participants, serializer: Conclar::ParticipantSerializer ), From a507b8f7c2dfe16dd7cf9b197762a986f587b5e2 Mon Sep 17 00:00:00 2001 From: Henry Date: Fri, 22 Jul 2022 08:31:38 -0400 Subject: [PATCH 09/19] removed condition that was hiding signed in --- app/javascript/people/people_table.vue | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/javascript/people/people_table.vue b/app/javascript/people/people_table.vue index af6eb31f4..e3de1cb8e 100644 --- a/app/javascript/people/people_table.vue +++ b/app/javascript/people/people_table.vue @@ -98,11 +98,9 @@