Add ratings to movies
This commit is contained in:
17
Rakefile
17
Rakefile
@@ -25,11 +25,26 @@ namespace :blog do
|
||||
title: title,
|
||||
year: activity.year,
|
||||
url: activity.film_link,
|
||||
watched_at: activity.watched_at
|
||||
watched_at: activity.watched_at,
|
||||
rating: (activity.score / 2.0)
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
task load_twitter_archive: ["blog:load_environment"] do
|
||||
require "hanami/prepare"
|
||||
|
||||
repo = Micropub::Container["repos.post_repo"]
|
||||
file = "tmp/tweets.json"
|
||||
tweets = JSON.parse(File.read(file))
|
||||
tweets.each do |tweet|
|
||||
next if tweet["tweet"]["full_text"].start_with? "@"
|
||||
tweet["tweet"]["full_text"] = tweet["tweet"]["full_text"].gsub(/(#{URI::DEFAULT_PARSER.make_regexp})/, "<a href='#{$1}'>#{$1}</a>")
|
||||
|
||||
repo.create({slug: tweet["tweet"]["id"], content: tweet["tweet"]["full_text"], published_at: tweet["tweet"]["created_at"], category: [], post_type: "post", syndication_sources: {twitter: "https://twitter.com/nitza/status/#{tweet["tweet"]["id"]}"}})
|
||||
end
|
||||
end
|
||||
|
||||
task scrobble_podcasts: ["blog:load_environment"] do
|
||||
require "hanami/prepare"
|
||||
|
||||
|
@@ -9,6 +9,7 @@ div class="mb-12 prose dark:prose-invert max-w-prose mx-auto text-gray-800 dark:
|
||||
tr
|
||||
td Title
|
||||
td Year
|
||||
td Rating
|
||||
- movies.each do |movie|
|
||||
tr
|
||||
td
|
||||
@@ -16,5 +17,10 @@ div class="mb-12 prose dark:prose-invert max-w-prose mx-auto text-gray-800 dark:
|
||||
= movie.title
|
||||
td
|
||||
= movie.year
|
||||
td class="min-w-32"
|
||||
- if movie.rating > 0
|
||||
== "#{'🌕' * movie.rating.floor}#{'🌗' * (movie.rating % movie.rating.floor).ceil}"
|
||||
- else
|
||||
== " "
|
||||
|
||||
div class="max-w-screen-md mx-auto border-t border-solid border-gray-200 dark:border-gray-600"
|
||||
|
9
db/migrate/20240125232452_add_rating_to_movies.rb
Normal file
9
db/migrate/20240125232452_add_rating_to_movies.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
ROM::SQL.migration do
|
||||
change do
|
||||
alter_table(:movies) do
|
||||
add_column :rating, :float, default: 0.0
|
||||
end
|
||||
end
|
||||
end
|
@@ -9,7 +9,11 @@ module Admin
|
||||
def call(movie)
|
||||
repo = Container["repos.movie_repo"]
|
||||
|
||||
return if repo.by_title_and_year(title: movie[:title], year: movie[:year])
|
||||
db_movie = repo.by_title_and_year(title: movie[:title], year: movie[:year])
|
||||
if db_movie
|
||||
repo.update(db_movie.id, rating: movie[:rating])
|
||||
return
|
||||
end
|
||||
|
||||
page = Down.download(movie[:url])
|
||||
match = page.read.match(/href=".+title\/(tt\d+)\/maindetails"/)
|
||||
|
Reference in New Issue
Block a user