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

TVOC param in data and get weather station by id #18

Merged
merged 2 commits into from
Jan 19, 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
3 changes: 3 additions & 0 deletions src/modules/weather-data/dto/get-weather-datum.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,7 @@ export class GetWeatherDatumDto {

@Prop()
readonly percentage_light_intensity: number;

@Prop()
readonly tvoc: number;
}
3 changes: 2 additions & 1 deletion src/modules/weather-data/weather-data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export class WeatherDataService {
* @param {any} datum - The weather datum object to be transformed.
* @returns {any} - The transformed weather datum object.
*/
transformWeatherDatum(datum) {
transformWeatherDatum(datum): GetWeatherDatumDto {
return {
_id: datum._id,
author_user_id: datum.metadata?.author_user_id,
Expand All @@ -179,6 +179,7 @@ export class WeatherDataService {
precipitation: datum.precipitation,
solar_irradiance: datum.solar_irradiance,
percentage_light_intensity: datum.percentage_light_intensity,
tvoc: datum.tvoc,
};
}

Expand Down
11 changes: 2 additions & 9 deletions src/modules/weather-stations/weather-stations.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class WeatherStationsController {

@Get(':id')
findOne(@Param('id') id: string) {
return this.weatherStationsService.findOne(+id);
return this.weatherStationsService.findOne(id);
}

// TODO: refactor to weather-data module.
Expand All @@ -76,14 +76,7 @@ export class WeatherStationsController {
}

// Get points of the user of the weather station.
let pointsOfUser = null;
if (!weatherData) {
return {
weatherData,
pointsOfUser,
};
}
pointsOfUser = await this.pointsService.findByUserId(
const pointsOfUser = await this.pointsService.findByUserId(
weatherData.author_user_id,
);

Expand Down
4 changes: 2 additions & 2 deletions src/modules/weather-stations/weather-stations.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ export class WeatherStationsService {
return this.weatherStationModel.find();
}

findOne(id: number) {
return `This action returns a #${id} weatherStation`;
findOne(id: string) {
return this.weatherStationModel.findOne({ _id: id });
}

async update(_id: string, updateWeatherStationDto: UpdateWeatherStationDto) {
Expand Down
Loading