Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/yl 49 table design #19

Merged
merged 14 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
empty:
echo "empty"

# supabase
supabase-start:
supabase start
supabase-stop:
supabase stop

# migration
## make create-migrate-file name=""
create-migrate-file:
supabase migration new ${name}
migrate:
supabase migration up
reset-migrate:
supabase db reset


# create entity
create-entity:
$(shell ./scripts/create-entity.sh)
14 changes: 14 additions & 0 deletions batch-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM golang:1.22.0-alpine3.18

WORKDIR /app

COPY /batch-service /app

RUN go mod tidy && \
go install github.com/cosmtrek/air@v1.46.0 && \
go install github.com/volatiletech/sqlboiler/v4@latest && \
go install github.com/volatiletech/sqlboiler/v4/drivers/sqlboiler-psql@latest

EXPOSE 5555

CMD ["air", "-c", ".air.toml"]
26 changes: 12 additions & 14 deletions batch-service/cmd/main.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package main

import (
"cloud.google.com/go/firestore"
"context"
"database/sql"
"log"

"github.com/YukiOnishi1129/techpicks/batch-service/cmd/usecase"
"github.com/YukiOnishi1129/techpicks/batch-service/database"
"github.com/YukiOnishi1129/techpicks/batch-service/infrastructure/firestore/repository"
"github.com/joho/godotenv"
"log"
)

func main() {
Expand All @@ -18,24 +18,22 @@ func main() {
log.Fatalf("Error loading .env file")
return
}
client, err := database.CreateFirestoreClient(ctx)

db, err := database.Init()
if err != nil {
log.Fatalf("Failed to create client: %v", err)
log.Fatalf("Failed to init db: %v", err)
return
}
defer func(client *firestore.Client) {
err = client.Close()
defer func(db *sql.DB) {
err = db.Close()
if err != nil {
log.Fatalf("Failed to close client: %v", err)
return
log.Fatalf("Failed to close db connection: %v", err)
}
}(client)
}(db)

pr := repository.NewPlatformRepository(client)
ar := repository.NewArticleRepository(client)
au := usecase.NewArticleUsecase(client, pr, ar)
au := usecase.NewArticleUsecase(db)

err = au.CreateArticles(ctx, client)
err = au.BatchCreateArticles(ctx)
if err != nil {
log.Fatalf("Failed to create articles: %v", err)
return
Expand Down
Loading
Loading