name Log call
type note(Call with Emily) template
action call with Emily
color green
templater true

const dateFormat = {dateStyle: 'medium', timeStyle: 'medium'};
 
dv.table(["Log", "Start Time", "End Time", "Duration"],
  dv.pages('"logs/Ambria\'s calls with Emily"')
    .sort(page => page['start-time'], 'desc')
    .where(page => !page['exclude-from-list'])
    .map(page => {
  	  const startTime = page['start-time'];
      const endTime = page['end-time'] || null;
      let duration;
      try {
        duration = (endTime && startTime) ? Duration.fromMillis(endTime - startTime).shiftTo('minutes', 'seconds').toFormat('m:ss') : null;
      } catch (error) {
        duration = 'Unable to calculate';
      }
     
      return [
        page.file.link,
        startTime ? startTime.toLocaleString(dateFormat) : null,
        endTime ? endTime.toLocaleString(dateFormat) : null,
        duration
      ];
    })
);