mvols
mvols
CCConvex Community
Created by mvols on 4/7/2025 in #general
Anyone have experience using the `Action
This is my internal action calling the getPricingHandler , when wrapped in the action cache component, its showing the fetch call & data structuring for pricing takes about 11.4 seconds with no action cache component & calling the action directly - the getPricingHandler takes only about 3 seconds:
4/7/2025, 8:14:52 AM [CONVEX A(actions/index:getPricingHandler)] [LOG] 'Internal total duration: 3209ms [3.209secs]'
4/7/2025, 8:14:52 AM [CONVEX A(actions/index:getPricingHandler)] [LOG] 'Internal total duration: 3209ms [3.209secs]'
2 replies
CCConvex Community
Created by mvols on 4/7/2025 in #general
Anyone have experience using the `Action
A little more insight - when logging the total duration of the handler within my pricing action:
4/7/2025, 8:12:39 AM [CONVEX A(actions/index:getPricingInternal)] [LOG] 'hitting a transaction response'
4/7/2025, 8:12:48 AM [CONVEX A(actions/index:getPricingInternal)] [LOG] 'Internal total duration: 11404ms [11.404secs]'
4/7/2025, 8:12:49 AM [CONVEX A(actions/index:getPricing)] [LOG] 'Cached total duration: 13079ms [13.079secs]'
4/7/2025, 8:12:39 AM [CONVEX A(actions/index:getPricingInternal)] [LOG] 'hitting a transaction response'
4/7/2025, 8:12:48 AM [CONVEX A(actions/index:getPricingInternal)] [LOG] 'Internal total duration: 11404ms [11.404secs]'
4/7/2025, 8:12:49 AM [CONVEX A(actions/index:getPricing)] [LOG] 'Cached total duration: 13079ms [13.079secs]'
2 replies
CCConvex Community
Created by mvols on 4/5/2025 in #general
deployment down
Yes thank you @Jamie My deployment is back up and running. Anything moving forward I should look out for if this happens again? or anything on my side id be able to do? Seemed like i was bricked out of my deployments, not able to run locally or achieve anything through the dashboard
3 replies
CCConvex Community
Created by RadiantFrog on 4/4/2025 in #support-community
Tanstack: How to call a Convex mutation from createServerFn?
wonder if you need to set the NEXT_PUBLIC_CONVEX_URL within the convex dashboard?
4 replies
CCConvex Community
Created by mvols on 1/17/2025 in #general
Batch insertions
dude get outta here, your kidding.. this has got to be one of the best (and coolest) services ive used to date! LOVE how this is all in TS and how unbelievably cool the dashboard is when writing/testing this stuff!
51 replies
CCConvex Community
Created by mvols on 1/17/2025 in #general
Batch insertions
so within that insert function, im doing this to check if its already been added:
export async function ensureUniqueCardPriceDoc(
ctx: QueryCtx,
args: CardPriceDoc
): Promise<Doc<"cardPricing"> | null> {
const { cardId, isoSnapshotDate, variant } = args;

return ctx.db
.query("cardPricing")
.withIndex("unique_card_id_and_snapshot_date_and_variant", (q) =>
q
.eq("cardId", cardId)
.eq("isoSnapshotDate", isoSnapshotDate)
.eq("variant", variant)
)
.unique();
}
export async function ensureUniqueCardPriceDoc(
ctx: QueryCtx,
args: CardPriceDoc
): Promise<Doc<"cardPricing"> | null> {
const { cardId, isoSnapshotDate, variant } = args;

return ctx.db
.query("cardPricing")
.withIndex("unique_card_id_and_snapshot_date_and_variant", (q) =>
q
.eq("cardId", cardId)
.eq("isoSnapshotDate", isoSnapshotDate)
.eq("variant", variant)
)
.unique();
}
so this being within the internalMutation would still count as only 1 fn call?
51 replies
CCConvex Community
Created by mvols on 1/17/2025 in #general
Batch insertions
thats much more palletable you think right to run each day. so the ctx.db.insert or ctx.db.query doesn't count towards function calls monthly it sounds like? just the actual internalActions or query from the client side?
51 replies
CCConvex Community
Created by mvols on 1/17/2025 in #general
Batch insertions
damn you a mad genius
51 replies
CCConvex Community
Created by mvols on 1/17/2025 in #general
Batch insertions
so here im only inserting 1 each time, but if i bump this to say take in an array of 200 cards, then the call to this internalMutation would only count as one per 200 cards? even tho we are calling ctx.db.insert for each single card (lets just say at the end of this function daily, i would be inserting 100k docs to keep numbers easy
51 replies
CCConvex Community
Created by mvols on 1/17/2025 in #general
Batch insertions
hm okay i think im grasping better now - so your saying in the internalMutation handle inserting an array of docs
/**
* Internal mutation to insert a card price document
* - runs validation checks on the input arguments
* - checks for uniqueness
*/
const internalInsertCardPriceDoc = internalMutation({
args: zodToConvex(cardPriceSchema),
handler: async (ctx, args) => {
const result = validateCardPriceArgs(args);
if (result.error) {
const errors = result.error.issues
.map((issue) => issue.message)
.join(", ");
throw new Error(
`[internalInsertCardPriceDoc] ${errors}, args:${JSON.stringify(args)}`
);
}

const existingCard = await ensureUniqueCardPriceDoc(ctx, args);
if (existingCard) {
throw new Error(
`[internalInsertCardPriceDoc] card pricing already exists, doc:${existingCard._id}, args:${JSON.stringify(
args
)}`
);
}

return ctx.db.insert("cardPricing", args);
},
});

export default internalInsertCardPriceDoc;
/**
* Internal mutation to insert a card price document
* - runs validation checks on the input arguments
* - checks for uniqueness
*/
const internalInsertCardPriceDoc = internalMutation({
args: zodToConvex(cardPriceSchema),
handler: async (ctx, args) => {
const result = validateCardPriceArgs(args);
if (result.error) {
const errors = result.error.issues
.map((issue) => issue.message)
.join(", ");
throw new Error(
`[internalInsertCardPriceDoc] ${errors}, args:${JSON.stringify(args)}`
);
}

const existingCard = await ensureUniqueCardPriceDoc(ctx, args);
if (existingCard) {
throw new Error(
`[internalInsertCardPriceDoc] card pricing already exists, doc:${existingCard._id}, args:${JSON.stringify(
args
)}`
);
}

return ctx.db.insert("cardPricing", args);
},
});

export default internalInsertCardPriceDoc;
51 replies
CCConvex Community
Created by mvols on 1/17/2025 in #general
Batch insertions
im working on my own historical pricing chart LOL so this is storing pricing on each card!
51 replies
CCConvex Community
Created by mvols on 1/17/2025 in #general
Batch insertions
omg get outta here this is for pokemon.. thats literally what im doing for my side project 😆
51 replies