Closed frankcollins3 closed 1 year ago
could've sworn I was doing this before with mydata.id I might've been doing me.id but even with users_id === users_id don't know how every column was being adjusted by one user. localStorage only has 1 user that has accurate id.
updateDailyData: {
type: DataType,
description: 'User already got Daily data and went through the daily water cycle. This is the end update',
args: {
users_id: { type: new GraphQLNonNull(GraphQLInt) },
progress: { type: new GraphQLNonNull(GraphQLInt) },
status: { type: new GraphQLList(GraphQLString) }
},
resolve: async (parent, args) => {
const { users_id, progress, status } = args;
const allusers = await allusersDB();
const alldata = await alldataDB()
const mydata = alldata.find(data => data.users_id = users_id)
let me = allusers.find(user => user.id === users_id);
return await prisma.data.update({
where: {
id: mydata.id
},
data: {
progress: progress,
status: status
// status: ['check', 'check', 'check', 'check', 'check']
},
}).then(updatedData => {
const d = updatedData;
return { google_id: d.google_id, date: d.date, progress: d.progress, weekday: d.weekday, status: d.status, users_id: d.users_id };
});
}
},
[1:04am]
part of this approach also comes with an attempt to solve the problem of the data fetching over and over. I set a boolean over the function so that if it sets to True, only run once. but that will still run once per every component.
This is a dynamic component that is returned within HYDRO_SCHEDULE.map() =>
startTime: 8am endTime: 16(4pm) notification-intensity: 2 hours. So [8am, 10am, 12pm, 2pm, 4pm] so this function fires 5x
proposed approach:
work backwards and see what's going on.