Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug/2234 fixing sqlite #2389

Merged
merged 3 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/server/api/conversations.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { addWhereClauseForContactsFilterMessageStatusIrrespectiveOfPastDue } fro
import { addCampaignsFilterToQuery } from "./campaign";
import { log } from "../../lib";
import { getConfig } from "../api/lib/config";
import { isSqlite } from "../models/index";

function getConversationsJoinsAndWhereClause(
queryParam,
Expand Down Expand Up @@ -146,6 +147,12 @@ function mapQueryFieldsToResolverFields(queryResult, fieldsMap) {
}
return key;
});
if (typeof data.updated_at != "undefined") {
data.updated_at = (
data.updated_at instanceof Date || !data.updated_at
? data.updated_at || null
: new Date(data.updated_at))
}
return data;
}

Expand Down Expand Up @@ -337,7 +344,9 @@ export async function getConversations(
let conversationCount;
try {
conversationCount = await r.getCount(
conversationsCountQuery.timeout(4000, { cancel: true })
!isSqlite ?
conversationsCountQuery.timeout(4000, { cancel: true }) :
conversationsCountQuery
);
} catch (err) {
// default fake value that means 'a lot'
Expand Down
7 changes: 6 additions & 1 deletion src/server/api/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@ import { Message } from "../models";
export const resolvers = {
Message: {
...mapFieldsToModel(
["text", "userNumber", "contactNumber", "createdAt", "isFromContact"],
["text", "userNumber", "contactNumber", "isFromContact"],
Message
),
createdAt: msg => (
msg.created_at instanceof Date || !msg.created_at
? msg.created_at || null
: new Date(msg.created_at)
),
media: msg =>
// Sometimes it's array, sometimes string. Maybe db vs. cache?
typeof msg.media === "string" ? JSON.parse(msg.media) : msg.media || [],
Expand Down
Loading