Skip to content

Commit

Permalink
remove time restrictions
Browse files Browse the repository at this point in the history
  • Loading branch information
Carrick Rogers committed May 20, 2016
1 parent c646628 commit dcbdd82
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/models/playlist.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ def related_items(current_item)
return_items
end

# Returns all other annotations on the same playlist that share a master file
# @param [PlaylistItem] current_item The playlist item you want to find matches for
# @return [Array <AvalonAnnotation>] an array of all other annotations items that reference the same master file
def related_annotations(current_item)
annotations = []
related_items(current_item).each do |item|
annotations << AvalonAnnotation.find(item.annotation_id)
end
annotations
end

# Returns a list of annotations who are on the same playlist, share the same masterfile, and whose start time falls within the start and end time of the current playlist item
# @param [PlaylistItem] current_item The playlist item to match against
# @return [Array <AvalonAnnotation>] all annotations matching the constraints
Expand Down
5 changes: 5 additions & 0 deletions spec/models/playlist_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
expect(@playlist.related_items(PlaylistItem.first).size).to eq(1)
expect(@playlist.related_items(PlaylistItem.last).size).to eq(0)
end
it 'returns a list of playlist annotations on the current playlist related to a playlist item' do
setup_playlist
expect(@playlist.related_annotations(PlaylistItem.first).size).to eq(1)
expect(@playlist.related_annotations(PlaylistItem.last).size).to eq(0)
end
it 'returns a list of annotations who start time falls within the time range of the current playlist item' do
setup_playlist
expect(@playlist.related_annotations_time_contrained(PlaylistItem.first).size).to eq(1)
Expand Down

0 comments on commit dcbdd82

Please sign in to comment.