import { ACCEPT_MAP } from 'src/resource/service/resource.service';
import { DataSource } from 'typeorm';

export async function handler(dataSource: DataSource, { user }) {
  return dataSource.query(`
    select sum(size) size, type from resource r
    where r.del_flag=0 and type in('${Object.keys(ACCEPT_MAP).join("','")}')
    ${user ? `and creator='${user.userId}'` : ''}
    group by type
    order by type
  `);
}
