only update with id = today
This commit is contained in:
@@ -5,7 +5,6 @@ dotenv.config();
|
||||
export const Config = {
|
||||
api_key: process.env.API_KEY,
|
||||
port: process.env.PORT || "8080",
|
||||
env_dev: process.env.ENV_DEV || false,
|
||||
|
||||
grist: {
|
||||
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 start = DateTime.fromObject(
|
||||
{ year: now.year, month: 1, day: 1, hour: 0, minute: 0 },
|
||||
|
||||
@@ -48,11 +48,15 @@ export async function privateHomepageRoutes(
|
||||
},
|
||||
},
|
||||
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([
|
||||
{
|
||||
component: "grist",
|
||||
data: gristService.transformToPersonalGoals(update[0]),
|
||||
data: gristService.transformToPersonalGoals(record),
|
||||
},
|
||||
]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user