import { DataSource } from 'typeorm';

export async function handler(dataSource: DataSource, { user }) {
  return dataSource.query(`
    select sum(r.size) size,r.type from report_data dr
    left join resource r
    on dr.field01=r.id
    where dr.type='RESOURCE_VIEW' and dr.creator='${user.userId}'
    group by r.type
    order by r.type
  `);
}
