Skip to content

Commit

Permalink
Merge pull request #13 from gaveshalabs/feat/weatherdata-metadata-ref…
Browse files Browse the repository at this point in the history
…actor

fixes
  • Loading branch information
RukshanJS authored Jan 8, 2024
2 parents 5d0dc2f + 6d78e45 commit c17fb5b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/modules/weather-data/entities/weather-datum.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from '../schema/weatherdata-metadata.schema';

@Schema({
timestamps: { createdAt: false, updatedAt: true },
timestamps: true,
collection: 'weather_data',
timeseries: {
timeField: 'timestamp',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { ICoordinates } from 'src/modules/common/interfaces/coordinates.interface';
import { User } from 'src/modules/users/entities/user.entity';
import { WeatherStation } from 'src/modules/weather-stations/entities/weather-station.entity';

@Schema({ timestamps: { createdAt: true, updatedAt: false } })
export class WeatherDataMetadata {
@Prop({ type: String, ref: WeatherStation.name })
@Prop({ type: String, ref: User.name })
author_user_id: string;

@Prop({ type: String, ref: WeatherStation.name })
Expand Down
5 changes: 1 addition & 4 deletions src/modules/weather-data/weather-data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ export class WeatherDataService {
const populatedData = filteredDataPoints.map((dataPoint) => {
return {
...dataPoint,
author_user_id,
weather_station_id,
coordinates,
metadata: {
author_user_id: author_user_id,
weather_station_id: weather_station_id,
Expand All @@ -100,7 +97,7 @@ export class WeatherDataService {
insertedData = await this.weatherDatumModel.insertMany(populatedData);

// Hacky checks to check if the data was inserted.
if (!insertedData || insertedData.length !== data.length) {
if (!insertedData || insertedData.length !== populatedData.length) {
throw new Error('Error inserting weather data');
}
} catch (error) {
Expand Down

0 comments on commit c17fb5b

Please sign in to comment.