Skip to content

Commit

Permalink
CSV should not have limit of 10
Browse files Browse the repository at this point in the history
  • Loading branch information
thewatermethod committed Feb 14, 2025
1 parent 14f892e commit b48c2db
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/services/communicationLog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,9 @@ const logsByScopes = async (
direction = 'desc',
limit: number = COMMUNICATION_LOGS_PER_PAGE,
scopes: WhereOptions[] = [],
format:'json' | 'csv' = 'json',
) => {
const scopedLogs = await CommunicationLog.findAndCountAll({
const queryParams = {
attributes: [
'id',
],
Expand All @@ -182,13 +183,23 @@ const logsByScopes = async (
as: 'author',
},
],
limit,
offset,
order: orderLogsBy(sortBy, direction),
});
} as {
attributes: string[];
where: WhereOptions;
include: WhereOptions[];
offset?: number;
order: string[];
limit?: number;
};

const scopedIds = scopedLogs.rows.map((log) => log.id);
if (format === 'json') {
queryParams.offset = offset;
queryParams.limit = limit;
}

const scopedLogs = await CommunicationLog.findAndCountAll(queryParams);
const scopedIds = scopedLogs.rows.map((log) => log.id);
const logs = await CommunicationLog
.findAll({
attributes: LOG_INCLUDE_ATTRIBUTES,
Expand Down Expand Up @@ -238,6 +249,7 @@ const csvLogsByScopes = async (
direction,
COMMUNICATION_LOGS_PER_PAGE,
scopes,
'csv',
);

// convert to csv
Expand Down

0 comments on commit b48c2db

Please sign in to comment.