only update with id = today
This commit is contained in:
@@ -5,7 +5,6 @@ dotenv.config();
|
|||||||
export const Config = {
|
export const Config = {
|
||||||
api_key: process.env.API_KEY,
|
api_key: process.env.API_KEY,
|
||||||
port: process.env.PORT || "8080",
|
port: process.env.PORT || "8080",
|
||||||
env_dev: process.env.ENV_DEV || false,
|
|
||||||
|
|
||||||
grist: {
|
grist: {
|
||||||
api_url: process.env.GRIST_API_URL || "",
|
api_url: process.env.GRIST_API_URL || "",
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ export class GristService extends BaseService<GristClient> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private getTodayAsId() {
|
getTodayAsId() {
|
||||||
const now = DateTime.now().setZone("Europe/Berlin");
|
const now = DateTime.now().setZone("Europe/Berlin");
|
||||||
const start = DateTime.fromObject(
|
const start = DateTime.fromObject(
|
||||||
{ year: now.year, month: 1, day: 1, hour: 0, minute: 0 },
|
{ year: now.year, month: 1, day: 1, hour: 0, minute: 0 },
|
||||||
|
|||||||
@@ -48,11 +48,15 @@ export async function privateHomepageRoutes(
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
async (request, reply) => {
|
async (request, reply) => {
|
||||||
const update = request.body as Record<string, unknown>[];
|
const updatedRecords = request.body as Record<string, unknown>[];
|
||||||
|
const record = updatedRecords[0];
|
||||||
|
if (record.id !== gristService.getTodayAsId()) {
|
||||||
|
return "no processing done. id not from today.";
|
||||||
|
}
|
||||||
const service_result = await hpService.updatePartial([
|
const service_result = await hpService.updatePartial([
|
||||||
{
|
{
|
||||||
component: "grist",
|
component: "grist",
|
||||||
data: gristService.transformToPersonalGoals(update[0]),
|
data: gristService.transformToPersonalGoals(record),
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
@@ -1,48 +1,48 @@
|
|||||||
### Simple GET Request
|
### Simple GET Request
|
||||||
GET http://localhost:8080/api/ping
|
GET http://localhost:8080/ping
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
#################### HA #######################
|
#################### HA #######################
|
||||||
|
|
||||||
### Simple GET Desk Position
|
### Simple GET Desk Position
|
||||||
GET http://localhost:8080/api/homeassistant/desk/position
|
GET http://localhost:8080/homeassistant/desk/position
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
### Simple GET Stand Automation
|
### Simple GET Stand Automation
|
||||||
GET http://localhost:8080/api/homeassistant/desk/stand
|
GET http://localhost:8080/homeassistant/desk/stand
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
### Simple POST Stand Automation
|
### Simple POST Stand Automation
|
||||||
POST http://localhost:8080/api/homeassistant/desk/stand
|
POST http://localhost:8080/homeassistant/desk/stand
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
### Simple GET Temps
|
### Simple GET Temps
|
||||||
GET http://localhost:8080/api/homeassistant/temperature
|
GET http://localhost:8080/homeassistant/temperature
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
#################### TIDAL #######################
|
#################### TIDAL #######################
|
||||||
|
|
||||||
### Simple GET Song
|
### Simple GET Song
|
||||||
GET http://localhost:8080/api/tidal/song
|
GET http://localhost:8080/tidal/song
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
### Simple GET Song Formatted
|
### Simple GET Song Formatted
|
||||||
GET http://localhost:8080/api/tidal/songFormatted
|
GET http://localhost:8080/tidal/songFormatted
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
### Simple GET Volume
|
### Simple GET Volume
|
||||||
GET http://localhost:8080/api/tidal/volume
|
GET http://localhost:8080/tidal/volume
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
### Simple SET Volume
|
### Simple SET Volume
|
||||||
POST http://localhost:8080/api/tidal/volume
|
POST http://localhost:8080/tidal/volume
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|||||||
Reference in New Issue
Block a user