all working

This commit is contained in:
Pedro Pérez 2025-01-28 21:59:53 +01:00
parent 1786100052
commit 955ac89c1a
28 changed files with 3355 additions and 2300 deletions

View File

@ -3,10 +3,13 @@
All notable change notes in this project will be documented in this file. All notable change notes in this project will be documented in this file.
## [0.1.0-2] - 2023-04-09 ## [0.1.0-2] - 2023-04-09
### Changed ### Changed
- `docker-compose.yml`: Changed the volume path for the `init.sql` file: - `docker-compose.yml`: Changed the volume path for the `init.sql` file:
- From: `./schema.sql:/docker-entrypoint-initdb.d/schema.sql` - From: `./schema.sql:/docker-entrypoint-initdb.d/schema.sql`
- To: `./init.sql:/docker-entrypoint-initdb.d/init.sql` - To: `./init.sql:/docker-entrypoint-initdb.d/init.sql`
### Removed ### Removed
- `docker/schema.sql`: The file has been removed. The schema configuration has been moved to the `init.sql` file. - `docker/schema.sql`: The file has been removed. The schema configuration has been moved to the `init.sql` file.

View File

@ -81,8 +81,6 @@ pg-docs:
# Generate or recreate SQLC queries. # Generate or recreate SQLC queries.
sqlc: sqlc:
cd $(CORE_DIR) && sqlc generate cd $(CORE_DIR) && sqlc generate
make gomock
.PHONY: test .PHONY: test
# Test all files and generate coverage file. # Test all files and generate coverage file.
@ -120,9 +118,10 @@ tidy:
.PHONY: build-linux .PHONY: build-linux
# Build and generate linux executable. # Build and generate linux executable.
build-linux: build-linux:
cd $(CORE_DIR) && make tidy cd $(CORE_DIR) && go mod tidy
cd $(CORE_DIR) && make remove-debug cd $(CORE_DIR) && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./tmp/$(MOD_NAME) ./cmd/.
cd $(CORE_DIR) && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./tmp/arena ./cmd/.
.PHONY: pack-docker .PHONY: pack-docker
# Run docker build for pack binary and assets to Docker container. # Run docker build for pack binary and assets to Docker container.

View File

@ -1,20 +1,20 @@
# Rating Orama # Rating Orama
Rating Orama is a web application for displaying TV show ratings and statistics. Rating Orama is a web application for displaying TV show ratings and statistics.
It is composed of 2 main parts: It is composed of 2 main parts:
1. **Core**: Written in Go and Fiber, responsible for orchestrating everything 1. **Core**: Written in Go and Fiber, responsible for orchestrating everything
and displaying the data using a template engine. and displaying the data using a template engine.
3. **Database**: PostgreSQL for storing data. 2. **Database**: PostgreSQL for storing data.
## Running the project ## Running the project
There are two ways to run the project: launching each part individually or There are two ways to run the project: launching each part individually or
building the Dockerfile and running it using Docker Compose. Here's an example building the Dockerfile and running it using Docker Compose. Here's an example
of the `docker-compose.yml` file for the latter option: of the `docker-compose.yml` file for the latter option:
```yaml ```yaml
version: '3' version: "3"
services: services:
core: core:
@ -49,5 +49,5 @@ volumes:
## Contributions ## Contributions
If you have ideas for improvements or bug fixes, feel free to contribute! To do If you have ideas for improvements or bug fixes, feel free to contribute! To do
so, simply clone the repository, create a new branch, and submit a pull request. so, simply clone the repository, create a new branch, and submit a pull request.

View File

@ -2,7 +2,6 @@ FROM alpine:3.20
WORKDIR /app WORKDIR /app
COPY ./database ./database COPY ../tmp/rating .
COPY ./tmp/rating .
CMD ["/app/rating"] CMD ["/app/rating"]

View File

@ -13,7 +13,7 @@ import (
"github.com/zepyrshut/rating-orama/internal/repository" "github.com/zepyrshut/rating-orama/internal/repository"
) )
const version = "0.2.0-beta.20241116-4" const version = "0.2.0-beta.20250128-1"
const appName = "rating-orama" const appName = "rating-orama"
func init() { func init() {
@ -25,6 +25,7 @@ var database embed.FS
func main() { func main() {
engine := html.New("./views", ".html") engine := html.New("./views", ".html")
engine.Reload(true)
app := app.NewExtendedApp(appName, version, ".env") app := app.NewExtendedApp(appName, version, ".env")
app.Migrate(database) app.Migrate(database)

View File

@ -7,6 +7,7 @@ import (
func router(h *handlers.Handlers, r *fiber.App) { func router(h *handlers.Handlers, r *fiber.App) {
r.Get("/", h.GetIndex)
r.Get("/tvshow", h.GetTVShow) r.Get("/tvshow", h.GetTVShow)
} }

View File

@ -1,6 +1,7 @@
package handlers package handlers
import ( import (
"encoding/json"
"log/slog" "log/slog"
"net/http" "net/http"
@ -10,6 +11,12 @@ import (
"github.com/zepyrshut/rating-orama/internal/sqlc" "github.com/zepyrshut/rating-orama/internal/sqlc"
) )
func (hq *Handlers) GetIndex(c *fiber.Ctx) error {
return c.Render("index", fiber.Map{
"Title": "Rating Orama",
}, "layouts/main")
}
func (hq *Handlers) GetTVShow(c *fiber.Ctx) error { func (hq *Handlers) GetTVShow(c *fiber.Ctx) error {
ttShowID := c.Query("ttid") ttShowID := c.Query("ttid")
@ -20,8 +27,9 @@ func (hq *Handlers) GetTVShow(c *fiber.Ctx) error {
var title string var title string
var scraperEpisodes []scraper.Episode var scraperEpisodes []scraper.Episode
var sqlcEpisodes []sqlc.Episode var sqlcEpisodes []sqlc.Episode
var totalVoteCount int32
tvShow, err := hq.queries.CheckTVShowExists(c.Context(), ttShowID) sqlcTvShow, err := hq.queries.CheckTVShowExists(c.Context(), ttShowID)
if err != nil { if err != nil {
title, scraperEpisodes = scraper.ScrapeEpisodes(ttShowID) title, scraperEpisodes = scraper.ScrapeEpisodes(ttShowID)
//TODO: make transactional //TODO: make transactional
@ -42,26 +50,61 @@ func (hq *Handlers) GetTVShow(c *fiber.Ctx) error {
slog.Error("failed to create episodes", "ttid", ttShowID, "error", err) slog.Error("failed to create episodes", "ttid", ttShowID, "error", err)
return c.SendStatus(http.StatusInternalServerError) return c.SendStatus(http.StatusInternalServerError)
} }
sqlcEpisodes = append(sqlcEpisodes, sqlcEpisode) sqlcEpisodes = append(sqlcEpisodes, sqlcEpisode)
} }
slog.Info("scraped seasons", "ttid", ttShowID, "title", title) slog.Info("scraped seasons", "ttid", ttShowID, "title", title)
} else { } else {
title = tvShow.Name title = sqlcTvShow.Name
sqlcEpisodes, err = hq.queries.GetEpisodes(c.Context(), tvShow.ID) sqlcEpisodes, err = hq.queries.GetEpisodes(c.Context(), sqlcTvShow.ID)
if err != nil { if err != nil {
slog.Error("failed to get episodes", "ttid", ttShowID, "error", err) slog.Error("failed to get episodes", "ttid", ttShowID, "error", err)
return c.SendStatus(http.StatusInternalServerError) return c.SendStatus(http.StatusInternalServerError)
} }
for _, episode := range sqlcEpisodes {
totalVoteCount += episode.VoteCount
}
hq.queries.IncreasePopularity(c.Context(), ttShowID) hq.queries.IncreasePopularity(c.Context(), ttShowID)
slog.Info("tv show exists", "ttid", ttShowID, "title", tvShow.Name) slog.Info("tv show exists", "ttid", ttShowID, "title", sqlcTvShow.Name)
} }
return c.JSON(fiber.Map{ episodesJSON, err := json.Marshal(sqlcEpisodes)
"popularity": tvShow.Popularity, if err != nil {
"title": title, slog.Error("failed to marshal episodes", "ttid", ttShowID, "error", err)
"seasons": sqlcEpisodes, return c.SendStatus(http.StatusInternalServerError)
}
// calculate avg rating for the show
avgRatingShow, err := hq.queries.TvShowAverageRating(c.Context(), sqlcTvShow.ID)
if err != nil {
slog.Error("failed to calculate avg rating for the show", "ttid", ttShowID, "error", err)
return c.SendStatus(http.StatusInternalServerError)
}
medianRatingShow, err := hq.queries.TvShowMedianRating(c.Context(), sqlcTvShow.ID)
if err != nil {
slog.Error("failed to calculate median rating for the show", "ttid", ttShowID, "error", err)
return c.SendStatus(http.StatusInternalServerError)
}
seasongAvgRatings, err := hq.queries.SeasonAverageRating(c.Context(), sqlc.SeasonAverageRatingParams{
TvShowID: sqlcTvShow.ID,
}) })
seasonMedianRatings, err := hq.queries.SeasonMedianRating(c.Context(), sqlc.SeasonMedianRatingParams{
TvShowID: sqlcTvShow.ID,
})
return c.Render("tvshow", fiber.Map{
"Title": sqlcTvShow.Name,
"tvshow": sqlcTvShow,
"episodes": string(episodesJSON),
"avg_rating_show": avgRatingShow,
"median_rating_show": medianRatingShow,
"season_avg_ratings": seasongAvgRatings,
"season_median_ratings": seasonMedianRatings,
"total_vote_count": totalVoteCount,
}, "layouts/main")
} }

View File

@ -9,8 +9,7 @@ sql:
out: "./internal/sqlc" out: "./internal/sqlc"
sql_package: "pgx/v5" sql_package: "pgx/v5"
emit_interface: true emit_interface: true
emit_empty_slices: true emit_empty_slices: true
emit_json_tags: true emit_json_tags: true
rename: rename:
uuid: "UUID" uuid: "UUID"

BIN
core/tmp/rating-orama Normal file

Binary file not shown.

View File

@ -1,101 +0,0 @@
{{template "partials/header" .}}
<div class="flex w-full flex-col items-center">
<h1 class="mb-6 text-3xl font-bold">{{ .TvShow.Title }}</h1>
<div class="mb-6 rounded-lg bg-white p-6 shadow-md">
<div class="mb-4 text-center">
<span class="text-gray-600">IMDb ID:</span>
<span class="font-semibold text-gray-800">{{ .TvShow.ShowID }}</span>
</div>
<div class="grid grid-cols-2 gap-8">
<ul class="space-y-2">
<li>
<span class="text-gray-600">Title:</span>
<span class="font-semibold text-gray-800">{{ .TvShow.Title }}</span>
</li>
<li>
<span class="text-gray-600">Runtime:</span>
<span class="font-semibold text-gray-800"
>{{ .TvShow.Runtime }} min</span
>
</li>
<li>
<span class="text-gray-600">Seasons:</span>
<span class="font-semibold text-gray-800">{{len .TvShow.Seasons }}</span>
</li>
</ul>
<ul class="space-y-2">
<li>
<span class="text-gray-600">Total votes:</span>
<span class="font-semibold text-gray-800">{{ .TvShow.Votes }}</span>
</li>
<li>
<span class="text-gray-600">Average rating:</span>
<span class="font-semibold text-gray-800"
>{{printf "%.2f" .TvShow.AvgRating }}</span
>
</li>
<li>
<span class="text-gray-600">Median rating:</span>
<span class="font-semibold text-gray-800"
>{{printf "%.2f" .TvShow.MedianRating }}</span
>
</li>
</ul>
</div>
</div>
<div class="mb-6 w-2/3">
<h2 class="mb-6 text-center text-2xl font-bold">Seasons overall</h2>
<canvas id="seasons"></canvas>
</div>
<div class="mb-6 w-2/3">
<div x-data="{ selectedSeasonNumber: 1}">
<h2 class="mb-6 text-center text-2xl font-bold">
Season <span x-text="selectedSeasonNumber"></span>
</h2>
<canvas id="episodes"></canvas>
<div class="mt-4 flex items-center justify-center space-x-2">
{{ range .TvShow.Seasons }}
<button
class="rounded-md border-2 border-black px-4 py-2 font-semibold text-black hover:bg-black hover:text-white"
:class="selectedSeasonNumber === {{ .Number }} ? 'bg-black text-white' : 'text-black'"
x-on:click="selectedSeasonNumber = {{ .Number }}; loadSeason({{ .Number }})"
>
S{{ .Number }}
</button>
{{ end }}
</div>
</div>
</div>
</div>
{{template "partials/footer" .}}
<script
src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.2.1/chart.umd.js"
integrity="sha512-vCUbejtS+HcWYtDHRF2T5B0BKwVG/CLeuew5uT2AiX4SJ2Wff52+kfgONvtdATqkqQMC9Ye5K+Td0OTaz+P7cw=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
></script>
<script type="module">
import { initCharts, loadSpecificSeason } from "/js/components/charts.js";
let tvShow = "{{ .TvShowJSON }}";
let tvShowParsed = JSON.parse(tvShow);
function loadSeason(season) {
const currentScrollY = window.scrollY;
loadSpecificSeason(tvShowParsed, season);
window.scrollTo(0, currentScrollY);
}
window.loadSeason = loadSeason;
document.addEventListener("DOMContentLoaded", function () {
initCharts(tvShowParsed);
});
</script>

File diff suppressed because one or more lines are too long

View File

@ -1,55 +1,22 @@
{{template "partials/header" .}} <div class="flex flex-col justify-center min-h-screen">
<div class="flex min-h-screen flex-col items-center justify-center"> <form class="max-w-md mx-auto w-full" action="/tvshow" method="get">
<h1 class="mb-6 text-3xl font-bold">Rating Orama</h1> <label for="default-search" class="mb-2 text-sm font-medium text-gray-900 sr-only dark:text-white">Buscar</label>
<div class="w-full max-w-md"> <div class="relative">
<form x-data="search" @submit.prevent="submit" class="flex items-center gap-3" > <div class="absolute inset-y-0 start-0 flex items-center ps-3 pointer-events-none">
<input <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"
x-model="ttID" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
class="rounded-md border-2 border-black bg-white px-4 py-2 w-11/12" class="lucide lucide-search">
id="search" <circle cx="11" cy="11" r="8" />
name="search" <path d="m21 21-4.3-4.3" />
type="text" </svg>
placeholder="tt0903747"
required
/>
<button
:disabled="isLoading"
class="rounded-md border-2 border-black bg-white px-4 py-2 font-bold text-black w-2/12"
type="submit"
:class="isLoading ? '' : 'hover:bg-black hover:text-white'"
>
<div class="flex items-center justify-center">
<template x-if="isLoading">
<div role="status">
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6 animate-spin fill-black text-white"
aria-hidden="true"
viewBox="0 0 100 101"
fill="none"
>
<path
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
fill="currentColor"
/>
<path
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
fill="currentFill"
/>
</svg>
<span class="sr-only">Cargando...</span>
</div>
</template>
<template x-if="!isLoading" class="lorem">
<span>Go!</span>
</template>
</div> </div>
<input type="search" id="default-search"
</button> class="block w-full p-4 ps-10 text-sm text-gray-900 border border-gray-300 rounded-lg bg-gray-50 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
</form> placeholder="IMDb ID" required
<p class="mt-2"> name="ttid"
Please input <span class="font-bold">tt id</span> from IDMb />
</p> <button type="submit"
</div> class="text-white absolute end-2.5 bottom-2.5 bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-4 py-2 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">Search</button>
</div>
</form>
</div> </div>

View File

@ -1,178 +0,0 @@
export function initCharts(tvShowParsed) {
new EpisodeChart(tvShowParsed, "episodes", 0);
new SeasonsChart(tvShowParsed, "seasons");
}
export function loadSpecificSeason(tvShowParsed, seasonId) {
new EpisodeChart(tvShowParsed, "episodes", seasonId - 1);
}
let chartInstance;
class SeasonsChart {
constructor(tvShowParsed, canvasId) {
this.tvShowParsed = tvShowParsed;
this.canvasId = canvasId;
this.createChart();
}
createChart() {
const seasons = this.tvShowParsed.seasons;
const labels = seasons.map((season) => `Season ${season.number}`);
const averageRating = seasons.map((season) => season.avg_rating);
const medianRating = seasons.map((season) => season.median_rating);
const votes = seasons.map((season) => season.votes);
const title = "Seasons"
const ctx = document.getElementById(this.canvasId);
new Chart(ctx, {
type: "bar",
data: {
labels: labels,
datasets: [
{
label: "Average rating",
data: averageRating,
backgroundColor: "rgba(75, 192, 192, 0.5)",
borderColor: "rgba(75, 192, 192, 1)",
borderWidth: 1,
Range: 10,
yAxisID: "y-axis-ratings",
},
{
label: "Median rating",
data: medianRating,
backgroundColor: "rgba(255, 206, 86, 0.5)",
borderColor: "rgba(255, 206, 86, 1)",
borderWidth: 1,
Range: 10,
yAxisID: "y-axis-ratings",
},
{
label: "Votes",
data: votes,
type: "line",
tension: 0.4,
fill: false,
borderColor: "rgba(255, 99, 132, 1)",
borderWidth: 2,
yAxisID: "y-axis-votes",
},
],
},
options: {
animation: {
duration: 0,
},
y: {
stacked: true,
},
scales: {
"y-axis-ratings": {
min: 0,
max: 10,
type: "linear",
display: true,
position: "left",
beginAtZero: true,
},
"y-axis-votes": {
type: "linear",
display: true,
position: "right",
beginAtZero: true,
},
},
},
plugins: {
title: {
display: true,
text: title,
},
}
});
}
}
class EpisodeChart {
constructor(tvShowParsed, canvasId, seasonId) {
this.tvShowParsed = tvShowParsed;
this.canvasId = canvasId;
this.seasonId = seasonId;
this.createChart();
}
createChart() {
if (chartInstance) {
chartInstance.destroy();
}
const episodes = this.tvShowParsed.seasons[this.seasonId].episodes;
const labels = episodes.map((episode) => `Ep. ${episode.number}`);
const ratings = episodes.map((episode) => episode.avg_rating);
const votes = episodes.map((episode) => episode.votes);
const title = `Episodes of season ${this.seasonId + 1}`
const ctx = document.getElementById(this.canvasId);
chartInstance = new Chart(ctx, {
type: "bar",
data: {
labels: labels,
datasets: [
{
label: "Average rating",
data: ratings,
backgroundColor: "rgba(75, 192, 192, 0.5)",
borderColor: "rgba(75, 192, 192, 1)",
borderWidth: 1,
Range: 10,
yAxisID: "y-axis-ratings",
},
{
label: "Votes",
data: votes,
type: "line",
tension: 0.4,
fill: false,
borderColor: "rgba(255, 99, 132, 1)",
borderWidth: 2,
yAxisID: "y-axis-votes",
},
],
},
options: {
animation: {
duration: 0,
},
scales: {
"y-axis-ratings": {
min: 0,
max: 10,
type: "linear",
display: true,
position: "left",
beginAtZero: true,
},
"y-axis-votes": {
type: "linear",
display: true,
position: "right",
beginAtZero: true,
},
},
plugins: {
tooltip: {
callbacks: {
title: function (context) {
const index = context[0].dataIndex;
const episode = episodes[index];
return `${episode.title} (${episode.aired.split("T")[0]})`;
},
},
},
},
},
});
}
}

View File

@ -1,19 +0,0 @@
export function search() {
return {
url: '/tv-show?id=',
ttID: '',
isLoading: false,
isError: false,
submit() {
this.isLoading = true;
fetch(this.url+this.ttID).then(response => {
if (response.ok) {
window.location.href = this.url+this.ttID;
} else {
this.isLoading = false;
this.isError = true;
}
});
}
}
}

View File

@ -1,8 +0,0 @@
import Alpine from "https://cdn.jsdelivr.net/npm/alpinejs@3.12.0/dist/module.esm.js";
import { search } from "./components/search.js";
window.Alpine = Alpine;
Alpine.data('search', search)
Alpine.start();

View File

@ -1,16 +1,17 @@
<!DOCTYPE html> <!doctype html>
<html lang="en"> <html lang="en">
<head>
<meta charset="UTF-8" />
<link type="image/svg+xml" href="/vite.svg" rel="icon" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href="/css/index.css" rel="stylesheet" />
<title>Rating Orama</title>
{{block "css" .}} {{end}}
</head>
<body class="min-h-screen bg-gray-100">
{{embed}}
<script type="module" src="/js/main.js"></script> <head>
</body> <meta charset="UTF-8" />
</html> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>{{ .Title }}</title>
<script src="https://unpkg.com/@tailwindcss/browser@4"></script>
</head>
<body class="min-h-screen bg-slate-50">
{{ embed }}
</body>
</html>

View File

@ -1,96 +1,51 @@
<footer class="bg-gray-200" aria-label="Site Footer">
<ul class="mt-12 flex justify-center gap-6 p-12">
<li>
<a
class="text-gray-700 transition hover:text-gray-700/75"
href="https://www.instagram.com/zepyrshut/"
rel="noreferrer"
target="_blank"
>
<span class="sr-only">Instagram</span>
<svg
class="h-6 w-6"
aria-hidden="true"
fill="currentColor"
viewBox="0 0 24 24"
>
<path
fill-rule="evenodd"
d="M12.315 2c2.43 0 2.784.013 3.808.06 1.064.049 1.791.218 2.427.465a4.902 4.902 0 011.772 1.153 4.902 4.902 0 011.153 1.772c.247.636.416 1.363.465 2.427.048 1.067.06 1.407.06 4.123v.08c0 2.643-.012 2.987-.06 4.043-.049 1.064-.218 1.791-.465 2.427a4.902 4.902 0 01-1.153 1.772 4.902 4.902 0 01-1.772 1.153c-.636.247-1.363.416-2.427.465-1.067.048-1.407.06-4.123.06h-.08c-2.643 0-2.987-.012-4.043-.06-1.064-.049-1.791-.218-2.427-.465a4.902 4.902 0 01-1.772-1.153 4.902 4.902 0 01-1.153-1.772c-.247-.636-.416-1.363-.465-2.427-.047-1.024-.06-1.379-.06-3.808v-.63c0-2.43.013-2.784.06-3.808.049-1.064.218-1.791.465-2.427a4.902 4.902 0 011.153-1.772A4.902 4.902 0 015.45 2.525c.636-.247 1.363-.416 2.427-.465C8.901 2.013 9.256 2 11.685 2h.63zm-.081 1.802h-.468c-2.456 0-2.784.011-3.807.058-.975.045-1.504.207-1.857.344-.467.182-.8.398-1.15.748-.35.35-.566.683-.748 1.15-.137.353-.3.882-.344 1.857-.047 1.023-.058 1.351-.058 3.807v.468c0 2.456.011 2.784.058 3.807.045.975.207 1.504.344 1.857.182.466.399.8.748 1.15.35.35.683.566 1.15.748.353.137.882.3 1.857.344 1.054.048 1.37.058 4.041.058h.08c2.597 0 2.917-.01 3.96-.058.976-.045 1.505-.207 1.858-.344.466-.182.8-.398 1.15-.748.35-.35.566-.683.748-1.15.137-.353.3-.882.344-1.857.048-1.055.058-1.37.058-4.041v-.08c0-2.597-.01-2.917-.058-3.96-.045-.976-.207-1.505-.344-1.858a3.097 3.097 0 00-.748-1.15 3.098 3.098 0 00-1.15-.748c-.353-.137-.882-.3-1.857-.344-1.023-.047-1.351-.058-3.807-.058zM12 6.865a5.135 5.135 0 110 10.27 5.135 5.135 0 010-10.27zm0 1.802a3.333 3.333 0 100 6.666 3.333 3.333 0 000-6.666zm5.338-3.205a1.2 1.2 0 110 2.4 1.2 1.2 0 010-2.4z"
clip-rule="evenodd"
/>
</svg>
</a>
</li>
<li> <footer class="bg-slate-200" aria-label="Site Footer">
<a <ul class="mt-12 flex justify-center gap-6 p-12">
class="text-gray-700 transition hover:text-gray-700/75" <li>
href="https://github.com/zepyrshut" <a
rel="noreferrer" class="text-slate-700 transition hover:text-slate-700/75"
target="_blank" href="https://www.instagram.com/modelektor/"
> rel="noreferrer"
<span class="sr-only">GitHub</span> target="_blank"
<svg >
class="h-6 w-6" <span class="sr-only">Instagram</span>
aria-hidden="true" <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-instagram"><rect width="20" height="20" x="2" y="2" rx="5" ry="5"/><path d="M16 11.37A4 4 0 1 1 12.63 8 4 4 0 0 1 16 11.37z"/><line x1="17.5" x2="17.51" y1="6.5" y2="6.5"/></svg>
fill="currentColor" </a>
viewBox="0 0 24 24" </li>
>
<path
fill-rule="evenodd"
d="M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z"
clip-rule="evenodd"
/>
</svg>
</a>
</li>
<li> <li>
<a <a
class="text-gray-700 transition hover:text-gray-700/75" class="text-slate-700 transition hover:text-slate-700/75"
href="https://pedroperez.dev/" href="https://github.com/zepyrshut"
rel="noreferrer" rel="noreferrer"
target="_blank" target="_blank"
> >
<span class="sr-only">Website</span> <span class="sr-only">GitHub</span>
<svg <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-github"><path d="M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"/><path d="M9 18c-4.51 2-5-2-7-2"/></svg>
class="h-6 w-6" </a>
fill="none" </li>
viewBox="0 0 24 24"
stroke-width="1.5" <li>
stroke="currentColor" <a
> class="text-slate-700 transition hover:text-slate-700/75"
<path href="https://pedroperez.dev/"
stroke-linecap="round" rel="noreferrer"
stroke-linejoin="round" target="_blank"
d="M12 21a9.004 9.004 0 008.716-6.747M12 21a9.004 9.004 0 01-8.716-6.747M12 21c2.485 0 4.5-4.03 4.5-9S14.485 3 12 3m0 18c-2.485 0-4.5-4.03-4.5-9S9.515 3 12 3m0 0a8.997 8.997 0 017.843 4.582M12 3a8.997 8.997 0 00-7.843 4.582m15.686 0A11.953 11.953 0 0112 10.5c-2.998 0-5.74-1.1-7.843-2.918m15.686 0A8.959 8.959 0 0121 12c0 .778-.099 1.533-.284 2.253m0 0A17.919 17.919 0 0112 16.5c-3.162 0-6.133-.815-8.716-2.247m0 0A9.015 9.015 0 013 12c0-1.605.42-3.113 1.157-4.418" >
/> <span class="sr-only">Website</span>
</svg> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-globe"><circle cx="12" cy="12" r="10"/><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"/><path d="M2 12h20"/></svg>
</a> </a>
</li> </li>
<li> <li>
<a <a
class="text-gray-700 transition hover:text-gray-700/75" class="text-slate-700 transition hover:text-slate-700/75"
href="https://github.com/zepyrshut/rating-orama" href="https://github.com/zepyrshut/rating-orama"
rel="noreferrer" rel="noreferrer"
target="_blank" target="_blank"
> >
<span class="sr-only">Source</span> <span class="sr-only">Source</span>
<svg <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-code-xml"><path d="m18 16 4-4-4-4"/><path d="m6 8-4 4 4 4"/><path d="m14.5 4-5 16"/></svg>
class="h-6 w-6" </a>
fill="none" </li>
viewBox="0 0 24 24" </ul>
stroke-width="1.5" </footer>
stroke="currentColor"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M17.25 6.75L22.5 12l-5.25 5.25m-10.5 0L1.5 12l5.25-5.25m7.5-3l-4.5 16.5"
/>
</svg>
</a>
</li>
</ul>
</footer>

View File

@ -1,3 +0,0 @@
<p class="mb-6 bg-yellow-400">
Work in progress - API 0.1.0 / Harvester 0.1.0 / Views 0.1.0 <a href="mailto:hola@pedroperez.dev" class="text-blue-800">Have you found any bugs or is it not working with a specific tv show?</a>
</p>

334
core/views/tvshow.html Normal file
View File

@ -0,0 +1,334 @@
<div class="flex flex-col items-center gap-4 mb-8 p-2">
<!-- Card header -->
<div class="flex flex-col items-center mt-4 bg-white p-4 rounded-lg shadow-md w-1/2">
<div class="flex flex-col items-center space-y-4 w-full">
<!-- Title section -->
<div class="text-center">
<h1 class="text-3xl font-bold text-gray-800">{{ .tvshow.Name }}</h1>
<div class="mt-1 flex items-center justify-center space-x-2">
<a href="https://www.imdb.com/title/{{ .tvshow.TtImdb }}" target="_blank"
class="text-amber-500 hover:text-amber-600 flex items-center space-x-1">
<svg class="w-4 h-4" fill="currentColor" viewBox="0 0 20 20">
<path
d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z" />
</svg>
<span class="font-semibold text-sm">{{ .tvshow.TtImdb }}</span>
</a>
</div>
</div>
<!-- Ratings section -->
<div class="grid grid-cols-2 gap-4 w-full">
<div class="bg-gray-50 rounded-lg p-2 text-center">
<span class="text-xs text-gray-500 uppercase">Average</span>
<div class="text-2xl font-bold text-gray-800">{{ printf "%.2f" .avg_rating_show }}</div>
</div>
<div class="bg-gray-50 rounded-lg p-2 text-center">
<span class="text-xs text-gray-500 uppercase">Median</span>
<div class="text-2xl font-bold text-gray-800">{{ printf "%.2f" .median_rating_show }}</div>
</div>
</div>
<!-- Stats section -->
<div class="flex justify-around w-full px-3 py-2 bg-gray-50 rounded-lg">
<div class="text-center">
<span class="text-xs text-gray-500">Vote count</span>
<div class="text-lg font-bold text-gray-800">{{ .total_vote_count }}</div>
</div>
<div class="text-center">
<span class="text-xs text-gray-500">Times searched</span>
<div class="text-lg font-bold text-gray-800">{{ .tvshow.Popularity }}</div>
</div>
</div>
</div>
</div>
<div class="w-4/5 mx-6">
<h2 class="mb-6 text-center text-2xl font-bold">Seasons overall</h2>
<canvas id="seasons"></canvas>
</div>
<div class="w-4/5">
<h2 class="mb-6 text-center text-2xl font-bold">Season <span id="seasonNumber">1</span></h2>
<div id="seasonButtons" class="mb-4 flex flex-wrap items-center justify-center gap-2"></div>
<canvas id="episodes"></canvas>
</div>
</div>
{{ template "partials/footer" . }}
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.4.1/chart.umd.js"
integrity="sha512-ZwR1/gSZM3ai6vCdI+LVF1zSq/5HznD3ZSTk7kajkaj4D292NLuduDCO1c/NT8Id+jE58KYLKT7hXnbtryGmMg=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script type="module">
const episodes = JSON.parse("{{ .episodes }}")
function groupEpisodesBySeason(episodes) {
const seasons = {};
episodes.forEach(episode => {
if (!seasons[episode.season]) {
seasons[episode.season] = {
number: episode.season,
episodes: [],
avg_rating: 0,
median_rating: 0,
votes: 0
};
}
seasons[episode.season].episodes.push({
number: episode.episode,
title: episode.name,
avg_rating: episode.avg_rating,
votes: episode.vote_count,
aired: episode.released
});
});
Object.values(seasons).forEach(season => {
const ratings = season.episodes.map(ep => ep.avg_rating);
season.avg_rating = ratings.reduce((a, b) => a + b, 0) / ratings.length;
season.median_rating = ratings.sort((a, b) => a - b)[Math.floor(ratings.length / 2)];
season.votes = season.episodes.reduce((sum, ep) => sum + ep.votes, 0);
});
return {
seasons: Object.values(seasons).sort((a, b) => a.number - b.number)
};
}
function createSeasonButtons() {
const maxSeason = Math.max(...episodes.map(ep => ep.season));
const buttonContainer = document.getElementById('seasonButtons');
const seasonNumberSpan = document.getElementById('seasonNumber');
for (let i = 1; i <= maxSeason; i++) {
const button = document.createElement('button');
button.textContent = `S${i}`;
button.className = 'rounded-md border-2 border-black px-4 py-2 font-semibold transition-colors duration-200 hover:bg-black hover:text-white';
if (i === 1) button.classList.add('bg-black', 'text-white');
button.addEventListener('click', (e) => {
e.preventDefault();
buttonContainer.querySelectorAll('button').forEach(btn => {
btn.classList.remove('bg-black', 'text-white');
btn.classList.add('text-black');
});
button.classList.remove('text-black');
button.classList.add('bg-black', 'text-white');
seasonNumberSpan.textContent = i;
const formattedData = groupEpisodesBySeason(episodes);
loadSpecificSeason(formattedData, i);
});
buttonContainer.appendChild(button);
}
}
document.addEventListener("DOMContentLoaded", function () {
const formattedData = groupEpisodesBySeason(episodes);
initCharts(formattedData);
createSeasonButtons();
});
function loadSeason(seasonNumber) {
const formattedData = groupEpisodesBySeason(episodes);
loadSpecificSeason(formattedData, seasonNumber);
}
function initCharts(tvShowParsed) {
new EpisodeChart(tvShowParsed, "episodes", 0);
new SeasonsChart(tvShowParsed, "seasons");
}
function loadSpecificSeason(tvShowParsed, seasonId) {
// Guardamos la posición actual del scroll
const currentScroll = window.scrollY;
new EpisodeChart(tvShowParsed, "episodes", seasonId - 1);
// Restauramos la posición del scroll
window.scrollTo(0, currentScroll);
}
let chartInstance;
class SeasonsChart {
constructor(tvShowParsed, canvasId) {
this.tvShowParsed = tvShowParsed;
this.canvasId = canvasId;
this.createChart();
}
createChart() {
const seasons = this.tvShowParsed.seasons;
const labels = seasons.map((season) => `Season ${season.number}`);
const averageRating = seasons.map((season) => season.avg_rating);
const medianRating = seasons.map((season) => season.median_rating);
const votes = seasons.map((season) => season.votes);
const title = "Seasons"
const ctx = document.getElementById(this.canvasId);
new Chart(ctx, {
type: "bar",
data: {
labels: labels,
datasets: [
{
label: "Average rating",
data: averageRating,
backgroundColor: "rgba(75, 192, 192, 0.5)",
borderColor: "rgba(75, 192, 192, 1)",
borderWidth: 1,
Range: 10,
yAxisID: "y-axis-ratings",
},
{
label: "Median rating",
data: medianRating,
backgroundColor: "rgba(255, 206, 86, 0.5)",
borderColor: "rgba(255, 206, 86, 1)",
borderWidth: 1,
Range: 10,
yAxisID: "y-axis-ratings",
},
{
label: "Votes",
data: votes,
type: "line",
tension: 0.4,
fill: false,
borderColor: "rgba(255, 99, 132, 1)",
borderWidth: 2,
yAxisID: "y-axis-votes",
},
],
},
options: {
animation: {
duration: 0,
},
y: {
stacked: true,
},
scales: {
"y-axis-ratings": {
min: 0,
max: 10,
type: "linear",
display: true,
position: "left",
beginAtZero: true,
},
"y-axis-votes": {
type: "linear",
display: true,
position: "right",
beginAtZero: true,
},
},
},
plugins: {
title: {
display: true,
text: title,
},
}
});
}
}
class EpisodeChart {
constructor(tvShowParsed, canvasId, seasonId) {
this.tvShowParsed = tvShowParsed;
this.canvasId = canvasId;
this.seasonId = seasonId;
this.createChart();
}
createChart() {
if (chartInstance) {
chartInstance.destroy();
}
const episodes = this.tvShowParsed.seasons[this.seasonId].episodes;
const labels = episodes.map((episode) => `Ep. ${episode.number}`);
const ratings = episodes.map((episode) => episode.avg_rating);
const votes = episodes.map((episode) => episode.votes);
const title = `Episodes of season ${this.seasonId + 1}`
const ctx = document.getElementById(this.canvasId);
chartInstance = new Chart(ctx, {
type: "bar",
data: {
labels: labels,
datasets: [
{
label: "Average rating",
data: ratings,
backgroundColor: "rgba(75, 192, 192, 0.5)",
borderColor: "rgba(75, 192, 192, 1)",
borderWidth: 1,
Range: 10,
yAxisID: "y-axis-ratings",
},
{
label: "Votes",
data: votes,
type: "line",
tension: 0.4,
fill: false,
borderColor: "rgba(255, 99, 132, 1)",
borderWidth: 2,
yAxisID: "y-axis-votes",
},
],
},
options: {
animation: {
duration: 0,
},
scales: {
"y-axis-ratings": {
min: 0,
max: 10,
type: "linear",
display: true,
position: "left",
beginAtZero: true,
},
"y-axis-votes": {
type: "linear",
display: true,
position: "right",
beginAtZero: true,
},
},
plugins: {
tooltip: {
callbacks: {
title: function (context) {
const index = context[0].dataIndex;
const episode = episodes[index];
return `${episode.title} (${episode.aired.split("T")[0]})`;
},
},
},
},
},
});
}
}
</script>

View File

@ -1,28 +1,31 @@
version: '3' version: "3"
// TODO: update docker-compose
services: services:
core: core:
container_name: core-ratingorama container_name: rating-orama
image: core:0.1.0 image: rating-orama:latest
environment: environment:
DATASOURCE: ${DATASOURCE} DRIVERNAME: pgx
HARVESTER_API: ${HARVESTER_API} DATASOURCE: postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}?sslmode=disable
IS_PRODUCTION: ${IS_PRODUCTION} MIGRATE: true
ports: ports:
- "8086:8080" - "8086:8080"
networks: networks:
- ratingorama - ratingorama
db: db:
container_name: db-ratingorama container_name: db-ratingorama
image: postgres:15.2-alpine image: postgres:16.4-alpine3.20
environment: environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
volumes: volumes:
- ./init.sql:/docker-entrypoint-initdb.d/schema.sql - ratingorama_data:/var/lib/postgresql/data
- ./data:/var/lib/postgresql/data
networks: networks:
- ratingorama - ratingorama
networks: networks:
ratingorama: ratingorama:
volumes:
ratingorama_data:

View File

@ -1,4 +1,4 @@
<!DOCTYPE html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
@ -7,22 +7,18 @@
<title>Inicio</title> <title>Inicio</title>
</head> </head>
<body class="min-h-screen bg-gray-100"> <body class="min-h-screen bg-slate-50 p-2">
<p class="mb-6 bg-yellow-400">
Work in progress - API 0.1.0 / Harvester 0.1.0 / Views 0.1.0
<a class="text-blue-800" href="mailto:hola@pedroperez.dev"
>Have you found any bugs or is it not working with a specific tv
show?</a
>
</p>
<div class="flex w-full flex-col items-center"> <div class="flex w-full flex-col items-center mt-6">
<h1 class="mb-6 text-3xl font-bold">Breaking Bad</h1> <h1 class="mb-6 text-4xl font-bold">Breaking Bad</h1>
<div class="mb-6 rounded-lg bg-white p-6 shadow-md"> <div class="mb-6 rounded-lg bg-white p-6 shadow-sm border border-gray-200">
<div class="mb-4 text-center"> <div class="mb-4 text-center">
<span class="text-gray-600">IMDb ID:</span> <span class="text-gray-600">IMDb ID: </span>
<span class="font-semibold text-gray-800">0903747</span> <span class="font-semibold text-gray-800">tt0903747</span>
</div> </div>
<div class="grid grid-cols-2 gap-8"> <div class="grid grid-cols-2 gap-8">
@ -115,23 +111,12 @@
<li> <li>
<a <a
class="text-gray-700 transition hover:text-gray-700/75" class="text-gray-700 transition hover:text-gray-700/75"
href="https://www.instagram.com/zepyrshut/" href="https://www.instagram.com/modelektor/"
rel="noreferrer" rel="noreferrer"
target="_blank" target="_blank"
> >
<span class="sr-only">Instagram</span> <span class="sr-only">Instagram</span>
<svg <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-instagram"><rect width="20" height="20" x="2" y="2" rx="5" ry="5"/><path d="M16 11.37A4 4 0 1 1 12.63 8 4 4 0 0 1 16 11.37z"/><line x1="17.5" x2="17.51" y1="6.5" y2="6.5"/></svg>
class="h-6 w-6"
aria-hidden="true"
fill="currentColor"
viewBox="0 0 24 24"
>
<path
fill-rule="evenodd"
d="M12.315 2c2.43 0 2.784.013 3.808.06 1.064.049 1.791.218 2.427.465a4.902 4.902 0 011.772 1.153 4.902 4.902 0 011.153 1.772c.247.636.416 1.363.465 2.427.048 1.067.06 1.407.06 4.123v.08c0 2.643-.012 2.987-.06 4.043-.049 1.064-.218 1.791-.465 2.427a4.902 4.902 0 01-1.153 1.772 4.902 4.902 0 01-1.772 1.153c-.636.247-1.363.416-2.427.465-1.067.048-1.407.06-4.123.06h-.08c-2.643 0-2.987-.012-4.043-.06-1.064-.049-1.791-.218-2.427-.465a4.902 4.902 0 01-1.772-1.153 4.902 4.902 0 01-1.153-1.772c-.247-.636-.416-1.363-.465-2.427-.047-1.024-.06-1.379-.06-3.808v-.63c0-2.43.013-2.784.06-3.808.049-1.064.218-1.791.465-2.427a4.902 4.902 0 011.153-1.772A4.902 4.902 0 015.45 2.525c.636-.247 1.363-.416 2.427-.465C8.901 2.013 9.256 2 11.685 2h.63zm-.081 1.802h-.468c-2.456 0-2.784.011-3.807.058-.975.045-1.504.207-1.857.344-.467.182-.8.398-1.15.748-.35.35-.566.683-.748 1.15-.137.353-.3.882-.344 1.857-.047 1.023-.058 1.351-.058 3.807v.468c0 2.456.011 2.784.058 3.807.045.975.207 1.504.344 1.857.182.466.399.8.748 1.15.35.35.683.566 1.15.748.353.137.882.3 1.857.344 1.054.048 1.37.058 4.041.058h.08c2.597 0 2.917-.01 3.96-.058.976-.045 1.505-.207 1.858-.344.466-.182.8-.398 1.15-.748.35-.35.566-.683.748-1.15.137-.353.3-.882.344-1.857.048-1.055.058-1.37.058-4.041v-.08c0-2.597-.01-2.917-.058-3.96-.045-.976-.207-1.505-.344-1.858a3.097 3.097 0 00-.748-1.15 3.098 3.098 0 00-1.15-.748c-.353-.137-.882-.3-1.857-.344-1.023-.047-1.351-.058-3.807-.058zM12 6.865a5.135 5.135 0 110 10.27 5.135 5.135 0 010-10.27zm0 1.802a3.333 3.333 0 100 6.666 3.333 3.333 0 000-6.666zm5.338-3.205a1.2 1.2 0 110 2.4 1.2 1.2 0 010-2.4z"
clip-rule="evenodd"
/>
</svg>
</a> </a>
</li> </li>
@ -143,18 +128,7 @@
target="_blank" target="_blank"
> >
<span class="sr-only">GitHub</span> <span class="sr-only">GitHub</span>
<svg <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-github"><path d="M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"/><path d="M9 18c-4.51 2-5-2-7-2"/></svg>
class="h-6 w-6"
aria-hidden="true"
fill="currentColor"
viewBox="0 0 24 24"
>
<path
fill-rule="evenodd"
d="M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z"
clip-rule="evenodd"
/>
</svg>
</a> </a>
</li> </li>
@ -166,19 +140,7 @@
target="_blank" target="_blank"
> >
<span class="sr-only">Website</span> <span class="sr-only">Website</span>
<svg <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-globe"><circle cx="12" cy="12" r="10"/><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"/><path d="M2 12h20"/></svg>
class="h-6 w-6"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M12 21a9.004 9.004 0 008.716-6.747M12 21a9.004 9.004 0 01-8.716-6.747M12 21c2.485 0 4.5-4.03 4.5-9S14.485 3 12 3m0 18c-2.485 0-4.5-4.03-4.5-9S9.515 3 12 3m0 0a8.997 8.997 0 017.843 4.582M12 3a8.997 8.997 0 00-7.843 4.582m15.686 0A11.953 11.953 0 0112 10.5c-2.998 0-5.74-1.1-7.843-2.918m15.686 0A8.959 8.959 0 0121 12c0 .778-.099 1.533-.284 2.253m0 0A17.919 17.919 0 0112 16.5c-3.162 0-6.133-.815-8.716-2.247m0 0A9.015 9.015 0 013 12c0-1.605.42-3.113 1.157-4.418"
/>
</svg>
</a> </a>
</li> </li>
<li> <li>
@ -189,19 +151,7 @@
target="_blank" target="_blank"
> >
<span class="sr-only">Source</span> <span class="sr-only">Source</span>
<svg <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-code-xml"><path d="m18 16 4-4-4-4"/><path d="m6 8-4 4 4 4"/><path d="m14.5 4-5 16"/></svg>
class="h-6 w-6"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M17.25 6.75L22.5 12l-5.25 5.25m-10.5 0L1.5 12l5.25-5.25m7.5-3l-4.5 16.5"
/>
</svg>
</a> </a>
</li> </li>
</ul> </ul>
@ -215,7 +165,10 @@
referrerpolicy="no-referrer" referrerpolicy="no-referrer"
></script> ></script>
<script type="module"> <script type="module">
import { initCharts, loadSpecificSeason } from "./src/components/charts.js"; import {
initCharts,
loadSpecificSeason,
} from "./src/components/charts.js";
import { data } from "./src/data/breaking-bad.js"; import { data } from "./src/data/breaking-bad.js";
const tvShowParsed = data; const tvShowParsed = data;

View File

@ -1,80 +1,43 @@
<!DOCTYPE html> <!doctype html>
<html lang="en"> <html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href="./src/styles/index.css" rel="stylesheet" />
<title>Inicio</title>
</head>
<body class="min-h-screen bg-gray-100"> <head>
<p class="mb-6 bg-yellow-400"> <meta charset="UTF-8" />
Work in progress - API 0.1.0 / Harvester 0.1.0 / Views 0.1.0 <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<a class="text-blue-800" href="mailto:hola@pedroperez.dev" <link href="./src/styles/index.css" rel="stylesheet" />
>Have you found any bugs or is it not working with a specific tv <title>Inicio</title>
show?</a </head>
>
</p> <body class="min-h-screen bg-slate-50 p-2">
<div class="flex min-h-screen flex-col items-center justify-center">
<h1 class="mb-6 text-3xl font-bold">Rating Orama</h1>
<div class="w-full max-w-md"> <div class="flex flex-col justify-center min-h-screen">
<form x-data="search" @submit.prevent="submit" class="flex items-center gap-3" > <form class="max-w-md mx-auto w-full">
<input <label for="default-search" class="mb-2 text-sm font-medium text-gray-900 sr-only dark:text-white">Buscar</label>
x-model="ttID" <div class="relative">
class="rounded-md border-2 border-black bg-white px-4 py-2 w-11/12" <div class="absolute inset-y-0 start-0 flex items-center ps-3 pointer-events-none">
id="search" <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"
name="search" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
type="text" class="lucide lucide-search">
placeholder="tt0903747" <circle cx="11" cy="11" r="8" />
required <path d="m21 21-4.3-4.3" />
/> </svg>
<button </div>
:disabled="isLoading" <input type="search" id="default-search"
class="rounded-md border-2 border-black bg-white px-4 py-2 font-bold text-black w-2/12" class="block w-full p-4 ps-10 text-sm text-gray-900 border border-gray-300 rounded-lg bg-gray-50 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
type="submit" placeholder="IMDb ID" required />
:class="isLoading ? '' : 'hover:bg-black hover:text-white'" <button type="submit"
> class="text-white absolute end-2.5 bottom-2.5 bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-4 py-2 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">Search</button>
<div class="flex items-center justify-center">
<template x-if="isLoading">
<div role="status">
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6 animate-spin fill-black text-white"
aria-hidden="true"
viewBox="0 0 100 101"
fill="none"
>
<path
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
fill="currentColor"
/>
<path
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
fill="currentFill"
/>
</svg>
<span class="sr-only">Cargando...</span>
</div>
</template>
<template x-if="!isLoading" class="lorem">
<span>Go!</span>
</template>
</div>
</button>
</form>
<p class="mt-2">
Please input <span class="font-bold">tt id</span> from IDMb
</p>
</div> </div>
</div> </form>
<script src="./src/main.js" type="module"></script> </div>
</body>
</html> <script src="./src/main.js" type="module"></script>
</body>
</html>

View File

@ -8,18 +8,16 @@
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"build": "vite build", "build": "vite build",
"preview": "vite preview" "preview": "vite preview",
"format": "prettier --write ."
}, },
"devDependencies": { "devDependencies": {
"@tailwindcss/forms": "^0.5.3", "prettier": "^3.4.2",
"autoprefixer": "^10.4.14", "prettier-plugin-organize-attributes": "^1.0.0",
"postcss": "^8.4.21", "prettier-plugin-tailwindcss": "^0.6.11",
"prettier": "^2.8.7", "standard": "^17.1.2",
"prettier-plugin-organize-attributes": "^0.0.5", "tailwindcss": "^4.0.0",
"prettier-plugin-tailwindcss": "^0.2.7", "vite": "^6.0.11"
"standard": "^17.0.0",
"tailwindcss": "^3.3.1",
"vite": "^4.2.1"
}, },
"standard": { "standard": {
"ignore": [ "ignore": [
@ -27,5 +25,8 @@
"dist", "dist",
"*.config.js" "*.config.js"
] ]
},
"dependencies": {
"@tailwindcss/vite": "^4.0.0"
} }
} }

4411
views-dev/pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +0,0 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {}
}
}

View File

@ -1,3 +1 @@
@tailwind base; @import "tailwindcss";
@tailwind components;
@tailwind utilities;

View File

@ -5,7 +5,5 @@ module.exports = {
theme: { theme: {
extend: {} extend: {}
}, },
plugins: [require('@tailwindcss/forms')({
strategy: 'class'
})]
} }

View File

@ -1,5 +1,9 @@
import { defineConfig } from 'vite' import { defineConfig } from 'vite'
import tailwindcss from '@tailwindcss/vite'
export default defineConfig({ export default defineConfig({
base: './' base: './',
plugins: [
tailwindcss()
]
}) })