Skip to content

Commit

Permalink
Merge pull request #36 from ritzalam/fix-attendee-join-times
Browse files Browse the repository at this point in the history
fix timestamp format for attendee joins and poll start times
  • Loading branch information
kepstin authored Jun 20, 2023
2 parents a676434 + b10bd5d commit 29622ea
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/bbbevents/attendee.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ def as_json
duration: @duration,
recent_talking_time: @recent_talking_time > 0 ? BBBEvents.format_datetime(Time.at(@recent_talking_time)) : '',
engagement: @engagement,
sessions: @sessions.map { |session| {
sessions: @sessions.map { |key, session| {
joins: session[:joins].map { |join| join.merge({ timestamp: BBBEvents.format_datetime(join[:timestamp])}) },
leaves: session[:leaves].map { |leave| leave.merge({ timestamp: BBBEvents.format_datetime(leave[:timestamp])}) }
lefts: session[:lefts].map { |leave| leave.merge({ timestamp: BBBEvents.format_datetime(leave[:timestamp])}) }
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions lib/bbbevents/poll.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,15 @@ def to_h
def to_json
JSON.generate(as_json)
end

def as_json
{
id: @id,
published: @published,
options: @options,
start: BBBEvents.format_datetime(@start),
votes: @votes
}
end
end
end
13 changes: 13 additions & 0 deletions spec/attendee_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,17 @@
expect(@attendee).to respond_to(:moderator?)
end
end

context "#joins?" do
it "has joins as array." do
expect(@attendee.joins).to be_a(Array)
expect(@attendee.as_json[:joins][0]).to eql('2018-08-16T15:39:21.000+00:00')
end
end

context "session#joins?" do
it "has session joins as array." do
expect(@attendee.as_json[:sessions][0][:joins][0][:timestamp]).to eql('2018-08-16T15:39:21.000+00:00')
end
end
end
7 changes: 7 additions & 0 deletions spec/poll_2_6_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,11 @@
expect(@poll).to respond_to(:published?)
end
end

context "#poll json timestamp format" do
it "has fixed poll json timestamp format." do
puts @poll.as_json[:start]
expect(@poll.as_json[:start]).to eq('2023-05-17T18:59:56.000+00:00')
end
end
end

0 comments on commit 29622ea

Please sign in to comment.