Skip to content

Commit

Permalink
Merge pull request #995 from PlanoramaEvents/plan-906-tags-on-publish
Browse files Browse the repository at this point in the history
Plan 906 tags on publish
  • Loading branch information
balen authored Jun 10, 2024
2 parents cc87f2a + ae112a5 commit 72710fc
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 7 deletions.
4 changes: 3 additions & 1 deletion app/controllers/publications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def schedule
SessionService.live_sessions
end

# TODO - check this
send_data XmlFormatter.new(sessions).render('schedule', sessions)
.gsub(/&lt;em&gt;/, '<em>')
.gsub(/&lt;\/em&gt;/, '</em>')
Expand All @@ -25,8 +26,9 @@ def schedule
.gsub(/\n\<\/timeduration\>/, '</timeduration>')
.gsub(/\n\<room\>/, '<room>')
.gsub(/\n\<areas\>/, ' - <areas>')
.gsub(/\n\<tags\>/, '<tags>')
.gsub(/\n\<format\>/, ', <format>')
.gsub(/\n\<\/roomareasformat\>/, '</roomareasformat>')
.gsub(/\n\<\/roomareasformattags\>/, '</roomareasformattags>')
.gsub(/\<participants\>\n/, '<participants>')
.gsub(/\<person\>\n/, '<person>')
.gsub(/\n\<person\>/, '<person>')
Expand Down
19 changes: 16 additions & 3 deletions app/serializers/conclar/session_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ class Conclar::SessionSerializer < ActiveModel::Serializer
object.start_time
end


attribute :tags do
attribute :areas do |session|
res = []

object.area_list.each do |area|
Expand All @@ -34,6 +33,20 @@ class Conclar::SessionSerializer < ActiveModel::Serializer
res << a
end

res
end

attribute :tags do
res = []

res = object.taggings.select{|t| t.context == 'tags'}.collect(&:tag).collect{|t|
{
value: "tag_".concat(t.name.gsub(/\s/,'_')),
category: "Tag",
label: t.name
}
}

case object.environment
when 'in_person'
t = {
Expand All @@ -53,7 +66,7 @@ class Conclar::SessionSerializer < ActiveModel::Serializer
t = {
value: "session_".concat(object.environment),
category: "Environment",
label: 'Virtual'
label: 'Online'
}
res << t
else
Expand Down
3 changes: 3 additions & 0 deletions app/services/publication_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ def self.publish_session(session:, update: true)

pub_session.send("#{attr}=", val) # the the attr in the publihsed instance
end
# Need to copy the tags to the puiblished session
pub_session.tag_list = session.tag_list

pub_session.session_id = session.id unless pub_session.session_id # point published to source session

pub_session
Expand Down
22 changes: 20 additions & 2 deletions app/services/session_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@ def self.published_sessions_unordered
'labels_list_table.labels_array',
'tags_list_table.tags_array'
)
.includes(:format, :room, {participant_assignments: :person})
.includes(
:format, :room,
{participant_assignments: :person},
{taggings: :tag}
)
.joins(self.area_subquery(clazz: PublishedSession))
.joins(self.tags_subquery(clazz: PublishedSession))
.joins(self.labels_subquery(clazz: PublishedSession))
Expand Down Expand Up @@ -120,6 +124,11 @@ def self.sessions
'labels_list_table.labels_array',
'tags_list_table.tags_array'
)
.includes(
:format, :room,
{participant_assignments: :person},
{taggings: :tag}
)
.joins(self.area_subquery)
.joins(self.tags_subquery)
.joins(self.labels_subquery)
Expand All @@ -133,7 +142,16 @@ def self.draft_sessions
end

def self.live_sessions
sessions.includes(:format, :room, {participant_assignments: :person})
Session.select(
::Session.arel_table[Arel.star],
'areas_list.area_list'
)
.includes(
:format, :room,
{participant_assignments: :person},
{taggings: :tag}
)
.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)
Expand Down
4 changes: 3 additions & 1 deletion app/views/xml_templates/schedule.nokogiri
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#
# XML template for a collection of sessions
#
# TODO:
xml.schedule {
# We need a <day> header at the start of the document, so
# before_1st_session needs to be at least 86400 seconds (the
Expand Down Expand Up @@ -33,14 +34,15 @@ xml.schedule {
xml.start_time(session.start_time.strftime("%-l:%M"))
xml.duration(session.duration)
}
xml.roomareasformat{
xml.roomareasformattags{
session.environment == 'virtual' ? xml.virtual(session.room.name) : xml.room(session.room.name)
xml.areas(session.area_list.join(", "))
if session.format
!session.area_list.include?(session.format.name) ? xml.format(session.format.name) : ""
end
session.streamed ? xml.streamed("- Livestream") : ""
session.recorded ? xml.recorded("- Recorded") : ""
xml.tags(session.tag_list.join(", "))
}
xml.description(session.description)
# If there are no visible participants, do not create an empty
Expand Down

0 comments on commit 72710fc

Please sign in to comment.