So would the best route be to add another array to formatOrders that would generate a list of mold_repairs, along with the start dates and end dates and then use that array to color the rows?
That's how I would do it, orders aren't repairs so it makes sense to me to keep them separate
So your loop in formatOrders would still be similar but in addition to getting orders for that product on that date it would also check for repairs for that product on that date
OK. I'll see if I can figure out how to do that.
Well, I worked on it all afternoon yesterday and into the evening and nothing I tried worked. Guess I didn't learn as much as I thought I did.
Hey Tom,
I've been following this thread and I think you've learned more than you think.
We've all been there, learning something new, getting stuck, get frustrated, wanting to throw everything over board, start over again, getting it done.
What was worked for me in the past when I've been in the same situation is focusing on other parts of my project for a couple of days and leave the learning settle. Try to think of other ways of achieving the same goal and bounce ideas with other people within the project/project leaders.
It very often happens that I have an insight that allows me to go back and finish what I was doing it, or redo it in a more efficient way.
In any case I want to give kudos to @dcartlidge. Appreciate your commitment to this thread!
Hey @MiguelOrtiz,
Thanks for your comments. I'm just hoping I can get this last piece of the puzzle in place and working. I feel that most everything else is now completed.
You've come a really long way in a short time on what really is a quite difficult problem.
Share where you got to and what you have tried?
Hey Tomm!
I've seen you on a few threads and you've been learning and building so much! Try not to compare yourself to others who have been building longer.
It's completely normal to feel challenged when tackling complex features. I've noticed your dedication and you're on the right path.
Are you free at 11 am Pacific Time? I think you would find office hours hugely beneficial and it would be great to talk to other builders and see that everyone is at different points in their respective developer journeys. We host it twice per week for an hour (Tuesday and Thursdays).
Here is the code that I currently have in place.
// a unique list of products from your database:
const product_list = {{ poolModels.data }};
console.log('The product list is ', product_list);
// a list of all the jobs from your database:
const order_list = {{ getOrders.data }};
console.log('The job list is ', order_list);
const repair_list = {{ moldRepair.data }};
console.log('The repair list is ', repair_list);
// the start date for reporting,
let reporting_date = moment('Mar 10, 2025', 'MMMM D, YYYY');
const reporting_range_days = 30;
let order_data = [];
for(let i=0; i<reporting_range_days; i++){
let today = reporting_date.format('YYYY-MM-DD'); // this format string is important - it must match what is in your jobs data
console.log('Finding orders for day ',i, ' which is the date ', today);
let o = order_list.filter(x => x.build_date === today); // filter the jobs by date, both of them in the format "YYYY-MM-DD"
let r = repair_list.filter(x=>x.start_date >= today && x.end_date <= today);
let d = {
orders: [],
date: today,
total_orders: o.length
};
console.log(o.length, ' orders have a build_date of ', today);
product_list.forEach(p => {
let po = o.filter(x => x.model === p.model_name);
if(po.length > 0) {
console.log(po.length, ' orders have a build_date of ', today ,' for model ', p.model_name);
}
d.orders.push(_.merge({
model: p.model_name,
build_date: null,
serial_no: null,
color: null,
add_ons: null,
proj_date: null,
mold_repair: null
}, po[0]));
});
reporting_date.add(1, 'days');
order_data.push(d);
}
console.log('The data for listview to display');
console.log(order_data);
return order_data;
From that point, I got lost. I tried running this as is and just got a blank page, so I figured what I had already put in there was wrong.
@AbbeyHernandez I will have to find time to attend. Today I am not available.
You're on the right lines here, nice work.
It looks like you have a list of the models and when they're being repaired, that's great.
You're also filtering the repair list to those repairs within the "today" window, again that logic looks sound.
The next step feels like you need to filter that list of "things being repaired today" by model too.
Just how you have the line which filters "today's orders" by model:
let po = o.filter(x => x.model === p.model_name);
I think you'd want to also filter the repair list by model too.
So the question you're asking is "what repairs are there today... for this model"
OK, so something like this?
// a unique list of products from your database:
const product_list = {{ poolModels.data }};
console.log('The product list is ', product_list);
// a list of all the jobs from your database:
const order_list = {{ getOrders.data }};
console.log('The job list is ', order_list);
const repair_list = {{ moldRepair.data }};
console.log('The repair list is ', repair_list);
// the start date for reporting,
let reporting_date = moment('Mar 10, 2025', 'MMMM D, YYYY');
const reporting_range_days = 30;
let order_data = [];
for(let i=0; i<reporting_range_days; i++){
let today = reporting_date.format('YYYY-MM-DD'); // this format string is important - it must match what is in your jobs data
console.log('Finding orders for day ',i, ' which is the date ', today);
let o = order_list.filter(x => x.build_date === today); // filter the jobs by date, both of them in the format "YYYY-MM-DD"
let r = repair_list.filter(x=>x.start_date >= today && x.end_date <= today);
let d = {
orders: [],
date: today,
total_orders: o.length
};
console.log(o.length, ' orders have a build_date of ', today);
product_list.forEach(p => {
let po = o.filter(x => x.model === p.model_name);
if(po.length > 0) {
console.log(po.length, ' orders have a build_date of ', today ,' for model ', p.model_name);
}
repair_list.forEach(p => {
let rp = r.filter(x=>x.model === p.model_name);
if(rp.length > 0) {
console.log(rp.length, ' models have a repair date of ', today ,' for model ', p.model_name):
}
d.orders.push(_.merge({
model: p.model_name,
build_date: null,
serial_no: null,
color: null,
add_ons: null,
proj_date: null,
mold_repair: null
}, po[0]));
});
reporting_date.add(1, 'days');
order_data.push(d);
}
console.log('The data for listview to display');
console.log(order_data);
return order_data;
I have to admit, I am totally lost now.
Hi @tomm,
It might help you to troubleshoot this in a Javascript query instead of a transformer so that you get more helpful error messages. You could try copy & pasting the code into a Javascript query, removing the any double curly brackets, and running the code there to see what errors come up. Once it runs error free, you can move it back to a transformer and add the double curly brackets back in.
Looking at the code snippet, this line looks like it shouldn't have a :
at the end. Can you try removing the colon?
console.log(rp.length, ' models have a repair date of ', today ,' for model ', p.model_name):
Also, it looks like the below lines need a closing parentheses and curly bracket. Can you try adding )}
after the }
?
order_data.push(d); }
If you take these steps and still run into errors, can you post the updated query and the response?
Or, can you share an app export with the data:
@Tess, thank you for your assistance. I tried moving the transformer over to a JS Query. This is the code I ended up with.
const product_list = poolModels.data;
console.log('The product list is ', product_list);
const order_list = getOrders.data;
console.log('The job list is ', order_list);
const repair_list = mold_repair.data;
let reporting_date = moment('Mar 10, 2025', 'MMMM D, YYYY');
const reporting_range_days = 30;
let order_data = [];
for(let i=0; i<reporting_range_days; i++){
let today = reporting_date.format('YYYY-MM-DD')
console.log('Finding orders for day ',i, ' which is the date ', today);
let o = order_list.filter(x => x.build_date === today);
let r = repair_list.filter(x => x.start_date >= today && x.end_date <= today);
let d = {
orders: [],
date: today,
total_orders: o.length
};
product_list.forEach(p => {
let po = o.filter(x => x.model === p.model_name);
if(po.length > 0) {
console.log(po.length, ' orders have a build_date of ', today ,' for model ', p.model_name)
}
repair_list.forEach(p => {
let rp = r.filter(x => x.model === p.model_name);
}
d.orders.push(_.merge({
model: p.model_name,
build_date: null,
serial_no: null,
color: null,
add_ons: null,
proj_date: null,
mold_repair: null
}, po[0]));
});
reporting_date.add(1, 'days');
order_data.push(d);
})
console.log('The data for listview to display');
console.log(order_data);
return order_data;
When I run that I get an error message that says missing ) after argument list
.
This is what I get in the console:
Also, here is the JSON file.
Admin.json (2.6 MB)
Please let me know if you need anything else.
Hi @tomm,
The Linting tab will be really helpful for you to troubleshoot query218 since it says which line the error occurs.
It looks like mold_repair is not defined. Should it be formatDataAsArray(moldRepair.data)
?
It looks like you can remove the curly bracket on line 26:
Then, we still need a closing parentheses and curly bracket, )}
, after order_data.push(d);}
I'm a bit late here, but is the problem just with scrolling 2 tables at the same time? It's a bit hacky (as you'll need to use auto generated class names) but you can accomplish this with just CSS. I actually found a JSFiddle example of it too
That's awesome!
Not sure on the status of this specific use case, since Tom posted here. But this is a good resource for anyone trying to set up a similar UI