Skip to content

Commit

Permalink
[PR] Revamp sec scraper backend (#269)
Browse files Browse the repository at this point in the history
* poc done but css needs work

* final mobile test then feature done

* remove comments, console logs, reset env

* update backend for revamped webscraper
  • Loading branch information
solderq35 authored Oct 20, 2023
1 parent f5aa2f8 commit 7a09726
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion backend/app/meter.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ exports.upload = async (event, context) => {
return response
}

let query_string = `INSERT INTO Solar_Meters (\`time\`, \`time_seconds\`, \`energy_change\`, \`tableid\`) VALUES ('${meter_data.time}', '${meter_data.time_seconds}', '${meter_data.totalYieldYesterday}', '${meter_data.tableID}');`
let query_string = `INSERT INTO Solar_Meters (\`time\`, \`time_seconds\`, \`energy_change\`, \`MeterID\`, \`MeterName\`) VALUES ('${meter_data.time}', '${meter_data.time_seconds}', '${meter_data.totalYieldYesterday}', '${meter_data.meterID}', '${meter_data.meterName}');`

try {
await DB.query(query_string)
Expand Down
15 changes: 6 additions & 9 deletions backend/dependencies/nodejs/models/meter.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,6 @@ class Meter {
if (String(meterClass).startsWith('999')) {
// get table name from meter table
let [{ name: meter_table_name }] = await DB.query('SELECT `name` FROM meters WHERE id = ?', [this.id])
const meterLookupTable = {
121: 'SEC_OSU_Op_Lube',
122: 'SEC_OSU_Op',
123: 'SEC_Solar',
124: 'OSU_Operations_Total'
}
if (meter_table_name.startsWith('M')) {
return DB.query(
'SELECT ' +
Expand All @@ -161,16 +155,19 @@ class Meter {
' WHERE time_seconds >= ? AND time_seconds <= ?',
[startTime, endTime]
)
} else {
}

// may have to modify the below to be else-if, if we are going to have multiple custom webscraper tables (Solar_Meters, etc)
else {
return DB.query(
'SELECT ' +
point +
", time_seconds AS time, '" +
this.id +
"' as id FROM " +
meter_table_name +
' WHERE time_seconds >= ? AND time_seconds <= ? AND tableID = ?',
[startTime, endTime, meterLookupTable[this.id]]
' WHERE time_seconds >= ? AND time_seconds <= ? AND MeterID = ?',
[startTime, endTime, this.id]
)
}
}
Expand Down

0 comments on commit 7a09726

Please sign in to comment.