mirror of
https://github.com/aykhans/movier.git
synced 2025-04-20 21:12:46 +00:00
Compare commits
2 Commits
62346bd3d4
...
3f7e1b94b6
Author | SHA1 | Date | |
---|---|---|---|
3f7e1b94b6 | |||
c6d680d0c0 |
29
README.md
29
README.md
@ -1,2 +1,27 @@
|
||||
## Data source
|
||||
https://datasets.imdbws.com/
|
||||
### Movier: Get Movie Recommendations Based on IMDb Data
|
||||
|
||||
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,7 +1,6 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
@ -36,7 +35,7 @@ func runServe() error {
|
||||
return err
|
||||
}
|
||||
db, err := postgresql.NewDB(dbURL)
|
||||
defer db.Close(context.Background())
|
||||
defer db.Close()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -13,9 +13,11 @@ require (
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/jackc/pgpassfile v1.0.0 // 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
|
||||
golang.org/x/crypto v0.27.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/text v0.18.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect
|
||||
|
@ -4,13 +4,15 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/jackc/pgx/v5"
|
||||
// "github.com/jackc/pgx/v5"
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
)
|
||||
|
||||
func NewDB(dbURL string) (*pgx.Conn, error) {
|
||||
conn, err := pgx.Connect(context.Background(), dbURL)
|
||||
func NewDB(dbURL string) (*pgxpool.Pool, error) {
|
||||
// conn, err := pgx.Connect(context.Background(), dbURL)
|
||||
dbpool, err := pgxpool.New(context.Background(), dbURL)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to connect to database: %w", err)
|
||||
}
|
||||
return conn, nil
|
||||
return dbpool, nil
|
||||
}
|
||||
|
@ -4,15 +4,16 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
|
||||
"github.com/aykhans/movier/server/pkg/dto"
|
||||
)
|
||||
|
||||
type IMDbRepository struct {
|
||||
db *pgx.Conn
|
||||
db *pgxpool.Pool
|
||||
}
|
||||
|
||||
func NewIMDbRepository(db *pgx.Conn) *IMDbRepository {
|
||||
func NewIMDbRepository(db *pgxpool.Pool) *IMDbRepository {
|
||||
return &IMDbRepository{
|
||||
db: db,
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user