mirror of
https://github.com/aykhans/movier.git
synced 2025-04-21 05:13:32 +00:00
Compare commits
No commits in common. "3f7e1b94b62c210d5527e3a3a74fd8008f7e4218" and "62346bd3d43dd8df2883c296e2b691c4d1e10642" have entirely different histories.
3f7e1b94b6
...
62346bd3d4
29
README.md
29
README.md
@ -1,27 +1,2 @@
|
|||||||
### Movier: Get Movie Recommendations Based on IMDb Data
|
## Data source
|
||||||
|
https://datasets.imdbws.com/
|
||||||
Movier recommends movies based on the IMDb dataset by comparing them with movies you provide.
|
|
||||||
|
|
||||||
:warning: This project is not production-ready.
|
|
||||||
|
|
||||||
## Data Source
|
|
||||||
This project uses non-commercial IMDb datasets, available at: [IMDb Datasets](https://datasets.imdbws.com/)
|
|
||||||
|
|
||||||
## How to Run
|
|
||||||
|
|
||||||
1. Rename the environment file:
|
|
||||||
Rename `/config/postgres/.env.example` to `/config/postgres/.env`:
|
|
||||||
```sh
|
|
||||||
mv ./config/postgres/.env.example ./config/postgres/.env
|
|
||||||
```
|
|
||||||
|
|
||||||
2. Run with Docker Compose:
|
|
||||||
Use Docker Compose to start the application:
|
|
||||||
```sh
|
|
||||||
docker compose up
|
|
||||||
```
|
|
||||||
|
|
||||||
*Downloading and extracting the datasets may take 5-10 minutes, depending on your network speed.*
|
|
||||||
|
|
||||||
3. Access the application:
|
|
||||||
Once the setup is complete, go to [http://localhost:8080](http://localhost:8080) to access Movier.
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -35,7 +36,7 @@ func runServe() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
db, err := postgresql.NewDB(dbURL)
|
db, err := postgresql.NewDB(dbURL)
|
||||||
defer db.Close()
|
defer db.Close(context.Background())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -13,11 +13,9 @@ require (
|
|||||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
|
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
|
||||||
github.com/jackc/puddle/v2 v2.2.2 // indirect
|
|
||||||
github.com/spf13/pflag v1.0.5 // indirect
|
github.com/spf13/pflag v1.0.5 // indirect
|
||||||
golang.org/x/crypto v0.27.0 // indirect
|
golang.org/x/crypto v0.27.0 // indirect
|
||||||
golang.org/x/net v0.28.0 // indirect
|
golang.org/x/net v0.28.0 // indirect
|
||||||
golang.org/x/sync v0.8.0 // indirect
|
|
||||||
golang.org/x/sys v0.25.0 // indirect
|
golang.org/x/sys v0.25.0 // indirect
|
||||||
golang.org/x/text v0.18.0 // indirect
|
golang.org/x/text v0.18.0 // indirect
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect
|
||||||
|
@ -4,15 +4,13 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
// "github.com/jackc/pgx/v5"
|
"github.com/jackc/pgx/v5"
|
||||||
"github.com/jackc/pgx/v5/pgxpool"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewDB(dbURL string) (*pgxpool.Pool, error) {
|
func NewDB(dbURL string) (*pgx.Conn, error) {
|
||||||
// conn, err := pgx.Connect(context.Background(), dbURL)
|
conn, err := pgx.Connect(context.Background(), dbURL)
|
||||||
dbpool, err := pgxpool.New(context.Background(), dbURL)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to connect to database: %w", err)
|
return nil, fmt.Errorf("failed to connect to database: %w", err)
|
||||||
}
|
}
|
||||||
return dbpool, nil
|
return conn, nil
|
||||||
}
|
}
|
||||||
|
@ -4,16 +4,15 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/jackc/pgx/v5"
|
"github.com/jackc/pgx/v5"
|
||||||
"github.com/jackc/pgx/v5/pgxpool"
|
|
||||||
|
|
||||||
"github.com/aykhans/movier/server/pkg/dto"
|
"github.com/aykhans/movier/server/pkg/dto"
|
||||||
)
|
)
|
||||||
|
|
||||||
type IMDbRepository struct {
|
type IMDbRepository struct {
|
||||||
db *pgxpool.Pool
|
db *pgx.Conn
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewIMDbRepository(db *pgxpool.Pool) *IMDbRepository {
|
func NewIMDbRepository(db *pgx.Conn) *IMDbRepository {
|
||||||
return &IMDbRepository{
|
return &IMDbRepository{
|
||||||
db: db,
|
db: db,
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user