Skip to content

Commit

Permalink
changing function controller/service naming and test availableTheater…
Browse files Browse the repository at this point in the history
…sEscapeGame service
  • Loading branch information
massahoudou authored and massahoudou committed Nov 4, 2023
1 parent a581f7a commit 2e5c8b7
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 328 deletions.
4 changes: 2 additions & 2 deletions src/controllers/theaters/theaters.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ export default class TheatersController implements BaseController {
}
}

public async getAvailableEscapeGameTheaters(res: Response): Promise<Response> {
public async getAvailableTheatersEscapeGame(res: Response): Promise<Response> {
try {
const data = await this.scrappingService.AvailableEscapeGameTheaters();
const data = await this.scrappingService.AvailableTheatersEscapeGame();
return res.status(StatusCodes.OK).json(data);

}catch(error) {
Expand Down
310 changes: 0 additions & 310 deletions src/docs/swagger-output.json
Original file line number Diff line number Diff line change
Expand Up @@ -1244,316 +1244,6 @@
}
}
}
},
"/escape/names": {
"get": {
"tags": [
"Theaters"
],
"summary": "Fetch all the available theaters name",
"description": "Return an array of strings with the theaters name",
"responses": {
"200": {
"description": "Ok",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/TheaterName"
},
"xml": {
"name": "main"
}
}
},
"application/xml": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/TheaterName"
},
"xml": {
"name": "main"
}
}
}
}
},
"400": {
"description": "Bad Request",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string",
"example": "Bad Request"
},
"errors": {
"type": "string",
"example": "any"
}
},
"xml": {
"name": "main"
}
}
},
"application/xml": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string",
"example": "Bad Request"
},
"errors": {
"type": "string",
"example": "any"
}
},
"xml": {
"name": "main"
}
}
}
}
}
}
}
},
"/escape/escape-game": {
"get": {
"description": "",
"responses": {
"default": {
"description": ""
}
}
}
},
"/escape/infos/{theaterSlug}": {
"get": {
"tags": [
"Theaters"
],
"summary": "Fetch informations about a specified theater giving his name",
"description": "Fetch informations about a specified theater giving his name",
"parameters": [
{
"name": "theaterSlug",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "lang",
"in": "query",
"description": "The response language",
"schema": {
"type": "string",
"enum": [
"fr",
"en"
]
}
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TheaterInfos"
}
},
"application/xml": {
"schema": {
"$ref": "#/components/schemas/TheaterInfos"
}
}
}
},
"400": {
"description": "Bad request",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string",
"example": "Bad request"
},
"errors": {
"type": "string",
"example": "any"
}
},
"xml": {
"name": "main"
}
}
},
"application/xml": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string",
"example": "Bad request"
},
"errors": {
"type": "string",
"example": "any"
}
},
"xml": {
"name": "main"
}
}
}
}
},
"404": {
"description": "Not found",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string",
"example": "Theater not found"
},
"errors": {
"type": "array",
"example": [],
"items": {}
}
},
"xml": {
"name": "main"
}
}
},
"application/xml": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string",
"example": "Theater not found"
},
"errors": {
"type": "array",
"example": [],
"items": {}
}
},
"xml": {
"name": "main"
}
}
}
}
},
"422": {
"description": "Your body was bad formatted",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string",
"example": "Your body was bad formatted"
},
"errors": {
"type": "array",
"items": {
"type": "object",
"properties": {
"type": {
"type": "string",
"example": "field"
},
"value": {
"type": "string",
"example": "zk"
},
"msg": {
"type": "string",
"example": "Invalid value"
},
"path": {
"type": "string",
"example": "lang"
},
"location": {
"type": "string",
"example": "query"
}
}
}
}
},
"xml": {
"name": "main"
}
}
},
"application/xml": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string",
"example": "Your body was bad formatted"
},
"errors": {
"type": "array",
"items": {
"type": "object",
"properties": {
"type": {
"type": "string",
"example": "field"
},
"value": {
"type": "string",
"example": "zk"
},
"msg": {
"type": "string",
"example": "Invalid value"
},
"path": {
"type": "string",
"example": "lang"
},
"location": {
"type": "string",
"example": "query"
}
}
}
}
},
"xml": {
"name": "main"
}
}
}
}
}
}
}
}
},
"components": {
Expand Down
2 changes: 1 addition & 1 deletion src/routes/theaters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ router.get('/escape-game',
ExpressValidatorMiddleware,

async function (req, res, _next) {
const response = theatersController.getAvailableEscapeGameTheaters(res);
const response = theatersController.getAvailableTheatersEscapeGame(res);
return response;
}

Expand Down
10 changes: 5 additions & 5 deletions src/services/scapping/scrapping.servive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,12 +446,12 @@ export default class ScrappingService implements BaseService {
throw Error(e.message);
}

// escape game by theaters
// escape game by theaters



}

public async AvailableEscapeGameTheaters(): Promise<TheaterEscapeGameModel[]> {
public async AvailableTheatersEscapeGame(): Promise<TheaterEscapeGameModel[]> {
let response: AxiosResponse;
try {
response = await axios.get(`${infos.baseUrl}/escape-game/`);
Expand All @@ -473,9 +473,9 @@ export default class ScrappingService implements BaseService {

htmlRoot(`article[data-${theaterName}]`).each((index, element) => {
const name = htmlRoot(element).children("h1").text();

const e = htmlRoot(element).children();

const description = e.find(".info-bloc p").text();
const difficulty = e.find("li.full").length;
const groupSizeMin = parseInt(e.find(".price").text().match(/Groupe de (\d+)/)?.[1] || "0");
Expand Down
Loading

0 comments on commit 2e5c8b7

Please sign in to comment.