Skip to content

Commit 32409b4

Browse files
committed
fixes from code review
1 parent 4c311d6 commit 32409b4

3 files changed

Lines changed: 13 additions & 14 deletions

File tree

apps/webapp/app/services/apiAuth.server.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -539,10 +539,7 @@ export async function authenticatedEnvironmentForAuthentication(
539539
const environment = await $replica.runtimeEnvironment.findFirst({
540540
where: {
541541
projectId: project.id,
542-
slug: slug,
543-
type: {
544-
in: ["PREVIEW", "DEVELOPMENT"],
545-
},
542+
type: slug === "dev" ? "DEVELOPMENT" : "PREVIEW",
546543
branchName: resolvedBranch,
547544
...(slug === "dev"
548545
? {
@@ -613,7 +610,6 @@ export async function authenticatedEnvironmentForAuthentication(
613610
const environment = await $replica.runtimeEnvironment.findFirst({
614611
where: {
615612
projectId: project.id,
616-
slug: slug,
617613
// No Development branches for OAT
618614
type: "PREVIEW",
619615
branchName: resolvedBranch,

apps/webapp/app/services/upsertBranch.server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ export async function checkBranchLimit({
236236
const baseLimit = await getLimit(organizationId, limitName, 100_000_000);
237237
const currentPlan = await getCurrentPlan(organizationId);
238238
const purchasedBranches = currentPlan?.v3Subscription?.addOns?.branches?.purchased ?? 0;
239+
// We deliberately include purchased PREVIEW branches in DEV limits... (not documented anywhere)
239240
const limit = baseLimit + purchasedBranches;
240241

241242
return {

apps/webapp/app/utils/environmentSort.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,19 @@ export function sortEnvironments<T extends SortType>(
2626
const difference = aIndex - bIndex;
2727

2828
if (difference === 0) {
29-
// Within the same env type, order by recency: most-recent dev activity
30-
// first, falling back to updatedAt when there's no recorded activity,
31-
// then to username when we have no timestamps at all.
32-
const aTime = (a.lastActivity ?? a.updatedAt)?.getTime();
33-
const bTime = (b.lastActivity ?? b.updatedAt)?.getTime();
29+
if (a.type === "DEVELOPMENT" && b.type === "DEVELOPMENT") {
30+
// Within the same env type, order by recency: most-recent dev activity
31+
// first, falling back to updatedAt when there's no recorded activity,
32+
// then to username when we have no timestamps at all.
33+
const aTime = (a.lastActivity ?? a.updatedAt)?.getTime();
34+
const bTime = (b.lastActivity ?? b.updatedAt)?.getTime();
3435

35-
if (aTime !== undefined && bTime !== undefined) {
36-
return bTime - aTime;
36+
if (aTime !== undefined && bTime !== undefined) {
37+
return bTime - aTime;
38+
}
39+
if (aTime !== undefined) return -1;
40+
if (bTime !== undefined) return 1;
3741
}
38-
if (aTime !== undefined) return -1;
39-
if (bTime !== undefined) return 1;
4042

4143
const usernameA = a.userName || "";
4244
const usernameB = b.userName || "";

0 commit comments

Comments
 (0)