Seperate new videos in subscription feed

This commit is contained in:
Omar Roth 2018-05-07 21:57:47 -05:00
parent 0e85a04761
commit fdcfe0bb14
3 changed files with 30 additions and 1 deletions

View File

@ -605,7 +605,7 @@ def get_user(sid, client, headers, db)
args = arg_array(user_array) args = arg_array(user_array)
db.exec("INSERT INTO users VALUES (#{args}) \ db.exec("INSERT INTO users VALUES (#{args}) \
ON CONFLICT (email) DO UPDATE SET id = $1, updated = $2, notifications = $3, subscriptions = $4", user_array) ON CONFLICT (email) DO UPDATE SET id = $1, updated = $2, subscriptions = $4", user_array)
end end
else else
user = fetch_user(sid, client, headers) user = fetch_user(sid, client, headers)

View File

@ -729,6 +729,11 @@ get "/feed/subscriptions" do |env|
videos = PG_DB.query_all("SELECT * FROM channel_videos WHERE ucid IN (#{args}) \ videos = PG_DB.query_all("SELECT * FROM channel_videos WHERE ucid IN (#{args}) \
ORDER BY published DESC LIMIT $1 OFFSET $2", [limit, offset] + user.subscriptions, as: ChannelVideo) ORDER BY published DESC LIMIT $1 OFFSET $2", [limit, offset] + user.subscriptions, as: ChannelVideo)
notifications = PG_DB.query_one("SELECT notifications FROM users WHERE email = $1", user.email, as: Array(String))
notifications = videos.select { |v| notifications.includes? v.id }
vidoes = videos - notifications
if !limit if !limit
videos = videos[0..max_results] videos = videos[0..max_results]
end end

View File

@ -2,6 +2,30 @@
<title>Subscriptions - Invidious</title> <title>Subscriptions - Invidious</title>
<% end %> <% end %>
<% if !notifications.empty? %>
<% notifications.each_slice(4) do |slice| %>
<div class="pure-g">
<% slice.each do |video| %>
<div class="pure-u-1 pure-u-md-1-4">
<div class="h-box">
<a style="width:100%;" href="/watch?v=<%= video.id %>">
<img style="width:100%;" src="https://i.ytimg.com/vi/<%= video.id %>/mqdefault.jpg"/>
<p style="height:100%"><%= video.title %></p>
</a>
<p>
<b><a style="width:100%;" href="https://youtube.com/channel/<%= video.ucid %>"><%= video.author %></a></b>
</p>
<p>
<h5>Shared <%= video.published.to_s("%B %-d, %Y at %r") %></h5>
</p>
</div>
</div>
<% end %>
</div>
<% end %>
<hr style="margin-left:1em; margin-right:1em;">
<% end %>
<% videos.each_slice(4) do |slice| %> <% videos.each_slice(4) do |slice| %>
<div class="pure-g"> <div class="pure-g">
<% slice.each do |video| %> <% slice.each do |video| %>