Skip to content

Commit

Permalink
Merge pull request #20 from moevm/points_of_interest
Browse files Browse the repository at this point in the history
Points of interest search implementation
  • Loading branch information
jonx8 authored Jan 21, 2025
2 parents e302d25 + af71fb5 commit a1b76da
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ import Point from "../dto/point";
export default class PointOfInterest {
id: string;
name: string;
description: string;
description: string[];
images: string[];
location: Point;
createdAt: string;

constructor(id: string, name: string, description: string, location: Point, createdAt: string) {
constructor(id: string, name: string, description: string[], images: string[], location: Point, createdAt: string) {
this.id = id;
this.name = name;
this.description = description;
this.images = images;
this.location = location;
this.createdAt = createdAt;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Body, Controller, Get, Param, Post, UsePipes, ValidationPipe } from '@nestjs/common';
import { Body, Controller, Get, Param, Post, Query, UsePipes, ValidationPipe } from '@nestjs/common';
import { PointsOfInterestService } from './points-of-interest.service';
import { CreatePointOfInterestDto } from "./dto/create-point-of-interest.dto";
import { Public } from "../authorization/public.decorator";
import { query } from 'express';

@Controller("/api/poi")
export class PointsOfInterestController {
Expand All @@ -16,8 +17,8 @@ export class PointsOfInterestController {

@Public()
@Get()
async findAll() {
return this.pointsOfInterestService.findAll();
async findAll(@Query('search') query: string) {
return this.pointsOfInterestService.findAll(query);
}

@Public()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Injectable, NotFoundException } from "@nestjs/common";
import { CreatePointOfInterestDto } from "./dto/create-point-of-interest.dto";
import { Neo4jService } from "../neo4j/neo4j.service";
import PointOfInterest from "./entities/point-of-interest.entity";
import { log } from "console";


@Injectable()
Expand Down Expand Up @@ -36,6 +37,7 @@ export class PointsOfInterestService {
node.elementId,
node.properties.name,
node.properties.description,
node.properties.images,
node.properties.location,
node.properties.created_at.toString(),
);
Expand All @@ -44,18 +46,22 @@ export class PointsOfInterestService {
}
}

async findAll() {
async findAll(query: string) {
const session = this.neo4jService.getReadSession();
try {
const result = await session.run(
`MATCH (poi :PointOfInterest) RETURN poi`
)
`MATCH (poi :PointOfInterest)
WHERE poi.name =~ '.*(?ui)${query ?? ''}.*'
RETURN poi`
);

return result.records.map(record => {
const node = record.get('poi');
return new PointOfInterest(
node.elementId,
node.properties.name,
node.properties.description,
node.properties.images,
node.properties.location,
node.properties.created_at.toString()
);
Expand All @@ -79,6 +85,7 @@ export class PointsOfInterestService {
node.elementId,
node.properties.name,
node.properties.description,
node.properties.images,
node.properties.location,
node.properties.created_at.toString(),
);
Expand Down
2 changes: 2 additions & 0 deletions server/src/modules/routes/routes.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export class RoutesService {
poi.elementId,
poi.properties.name,
poi.properties.description,
poi.properties.images,
poi.properties.location,
poi.properties.created_at.toString(),
));
Expand Down Expand Up @@ -149,6 +150,7 @@ export class RoutesService {
poi.elementId,
poi.properties.name,
poi.properties.description,
poi.properties.images,
poi.properties.location,
poi.properties.created_at.toString(),
));
Expand Down

0 comments on commit a1b76da

Please sign in to comment.