Skip to content

Commit

Permalink
chore: Fix edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandrovarelasc committed May 13, 2024
1 parent b9b7f78 commit a3782d0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions compute/server/src/consumer/consumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,17 @@ export class Consumer implements OnModuleInit {
break;
case SUBTOPIC.JSON:
const json = JSON.parse(message.value.toString());
let value = json.value;
let value = json.raw;
//Handle cases where value is different from a Double or number format
try {
value = parseFloat(json.value);
value = parseFloat(json.raw);
} catch (error) {
Logger.error(`Value ${json.value} is not a number!`);
Logger.error(`Value ${json.raw} is not a number!`);
return;
}
//If value is NaN or have N characters, return
if (isNaN(value) || json.raw.includes('N')) {
Logger.error(`Value ${json.raw} is not a number!`);
return;
}
const maxConsumption = parseInt(
Expand Down
2 changes: 1 addition & 1 deletion compute/server/src/jobs/job.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class JobsService {
* The main action is to make a request to the device ip (/value?all=true&type=value) to get all the measurements
* on sd card and save them in the database if they are not already saved
*/
@Cron(CronExpression.EVERY_DAY_AT_MIDNIGHT, {
@Cron(CronExpression.EVERY_30_MINUTES, {
name: 'measurementsOnDevice',
timeZone: 'America/Bogota',
})
Expand Down

0 comments on commit a3782d0

Please sign in to comment.