Skip to content

Commit

Permalink
try up prod
Browse files Browse the repository at this point in the history
  • Loading branch information
UnicoYal committed Dec 16, 2024
1 parent 734b389 commit 8d510a1
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 48 deletions.
2 changes: 1 addition & 1 deletion easyjson.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ internal/app/models/easy.go
internal/app/api/struct.go
internal/app/errors/errors.go
internal/app/room/model/model.go
internal/db/script_elastic/script.go
internal/db/script_elastic/models/models.go
movie_service/internal/movie/models/easy.go
2 changes: 1 addition & 1 deletion exclude_from_coverage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ github.com/go-park-mail-ru/2024_2_GOATS/internal/app/api/struct_easyjson.go
github.com/go-park-mail-ru/2024_2_GOATS/internal/app/errors/errors_easyjson.go
github.com/go-park-mail-ru/2024_2_GOATS/internal/app/errors/errors_easyjson.go
github.com/go-park-mail-ru/2024_2_GOATS/internal/app/room/model/model_easyjson.go
github.com/go-park-mail-ru/2024_2_GOATS/internal/db/script_elastic/script_easyjson.go
github.com/go-park-mail-ru/2024_2_GOATS/internal/db/script_elastic/models/models_easyjson.go
github.com/go-park-mail-ru/2024_2_GOATS/movie_service/internal/movie/models/easy_easyjson.go
2 changes: 0 additions & 2 deletions internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,7 @@ func (a *App) Run() {
srvRoom := roomServ.NewService(repoRoom, mvManager, usrManager, roomHub, timer)
delRoom := roomApi.NewRoomHandler(srvRoom, roomHub)

log.Println("XZXZXZ")
go roomHub.Run()
log.Println("XZ2XZ2XZ2")

mx := mux.NewRouter()
authMW := middleware.NewSessionMiddleware(srvAuth)
Expand Down
7 changes: 4 additions & 3 deletions internal/app/room/room_handler/delivery.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package delivery

import (
"context"
"fmt"

"github.com/go-park-mail-ru/2024_2_GOATS/config"
"github.com/go-park-mail-ru/2024_2_GOATS/internal/app/api"
Expand Down Expand Up @@ -41,14 +42,14 @@ func NewRoomHandler(service RoomServiceInterface, roomHub *ws.RoomHub) *RoomHand
}

func (h *RoomHandler) CreateRoom(w http.ResponseWriter, r *http.Request) {
var room model.RoomState
room := &model.RoomState{}
if !api.DecodeBody(w, r, room) {
return
}

createdRoom, err := h.roomService.CreateRoom(r.Context(), &room)
createdRoom, err := h.roomService.CreateRoom(r.Context(), room)
if err != nil {
http.Error(w, "Failed to create room", http.StatusInternalServerError)
http.Error(w, fmt.Sprintf("Failed to create room: %v", err), http.StatusInternalServerError)
return
}

Expand Down
24 changes: 24 additions & 0 deletions internal/db/script_elastic/models/models.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package models

// Movie data for elasticsearch
type Movie struct {
ID string `json:"id"`
Title string `json:"title"`
CardURL string `json:"card_url"`
AlbumURL string `json:"album_url"`
Rating float64 `json:"rating"`
ReleaseDate string `json:"release_date"`
MovieType string `json:"movie_type"`
Country string `json:"country"`
}

// Actor data for elasticsearch
type Actor struct {
ID string `json:"id"`
FullName string `json:"full_name"`
PhotoURL string `json:"photo_url"`
PhotoBigURL string `json:"photo_big_url"`
Biography string `json:"biography"`
Country string `json:"country"`
BirthDate string `json:"birth_date"`
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 7 additions & 28 deletions internal/db/script_elastic/script.go
Original file line number Diff line number Diff line change
@@ -1,35 +1,14 @@
package script_elastic
package main

import (
"bytes"
"fmt"
"log"
"net/http"
"time"
)

// Movie data for elasticsearch
type Movie struct {
ID string `json:"id"`
Title string `json:"title"`
CardURL string `json:"card_url"`
AlbumURL string `json:"album_url"`
Rating float64 `json:"rating"`
ReleaseDate string `json:"release_date"`
MovieType string `json:"movie_type"`
Country string `json:"country"`
}

// Actor data for elasticsearch
type Actor struct {
ID string `json:"id"`
FullName string `json:"full_name"`
PhotoURL string `json:"photo_url"`
PhotoBigURL string `json:"photo_big_url"`
Biography string `json:"biography"`
Country string `json:"country"`
BirthDate string `json:"birth_date"`
}
"github.com/go-park-mail-ru/2024_2_GOATS/internal/db/script_elastic/models"
)

func delIndex(indexName string) {
url := fmt.Sprintf("http://83.166.232.3:9200/%s", indexName)
Expand Down Expand Up @@ -94,7 +73,7 @@ func createIndex(indexName, mapping string) {
fmt.Printf("Response body: %s\n", body)
}

func addMovie(id int, movie Movie) {
func addMovie(id int, movie models.Movie) {
data, err := movie.MarshalJSON()
if err != nil {
log.Fatalf("Error marshaling movie_service data: %v", err)
Expand Down Expand Up @@ -123,7 +102,7 @@ func addMovie(id int, movie Movie) {
fmt.Printf("Response body: %s\n", body)
}

func addActor(id int, actor Actor) {
func addActor(id int, actor models.Actor) {
data, err := actor.MarshalJSON()
if err != nil {
log.Fatalf("Error marshaling actor data: %v", err)
Expand Down Expand Up @@ -196,7 +175,7 @@ func main() {
// Подождем, чтобы индексы были созданы
time.Sleep(2 * time.Second)

movies := []Movie{
movies := []models.Movie{
{
ID: "1",
Title: "Игра в кальмара",
Expand Down Expand Up @@ -446,7 +425,7 @@ func main() {
addMovie(i+1, movie)
}

actors := []Actor{
actors := []models.Actor{
{
ID: "1",
FullName: "Педро Гонсалес Алонсо",
Expand Down

0 comments on commit 8d510a1

Please sign in to comment.