diff --git a/src/client/features/domain/components/DomainSearchCard.tsx b/src/client/features/domain/components/DomainSearchCard.tsx index 99567c7..6ffa15f 100644 --- a/src/client/features/domain/components/DomainSearchCard.tsx +++ b/src/client/features/domain/components/DomainSearchCard.tsx @@ -78,7 +78,7 @@ export function DomainSearchCard({ className="select select-bordered shrink-0" value={field.state.value} onChange={(event) => { - const next = toSortMode(event.target.value) ?? "rank"; + const next = toSortMode(event.target.value) ?? "traffic"; field.handleChange(next); onSortChange(next); }} diff --git a/src/client/features/domain/domainRouteState.ts b/src/client/features/domain/domainRouteState.ts index 04d779d..8410a18 100644 --- a/src/client/features/domain/domainRouteState.ts +++ b/src/client/features/domain/domainRouteState.ts @@ -45,7 +45,7 @@ function numberToFilterString(value: number | undefined): string { export function getDomainRouteState( search: DomainSearchParams, ): DomainOverviewRouteState { - const normalizedSort = toSortMode(search.sort ?? null) ?? "rank"; + const normalizedSort = toSortMode(search.sort ?? null) ?? "traffic"; const normalizedLocationCode = search.loc != null && isSupportedLocationCode(search.loc) ? search.loc diff --git a/src/client/features/domain/utils.ts b/src/client/features/domain/utils.ts index 40bd963..3ee4e5b 100644 --- a/src/client/features/domain/utils.ts +++ b/src/client/features/domain/utils.ts @@ -37,7 +37,7 @@ export function resolveSortOrder( export function toSortSearchParam( sortMode: DomainSortMode, ): DomainSortMode | undefined { - return sortMode === "rank" ? undefined : sortMode; + return sortMode === "traffic" ? undefined : sortMode; } export function toSortOrderSearchParam( diff --git a/src/client/features/rank-tracking/KeywordSuggestionStep.tsx b/src/client/features/rank-tracking/KeywordSuggestionStep.tsx index 447e5db..051ba0d 100644 --- a/src/client/features/rank-tracking/KeywordSuggestionStep.tsx +++ b/src/client/features/rank-tracking/KeywordSuggestionStep.tsx @@ -160,7 +160,7 @@ export function KeywordSuggestionStep({ const [rowSelection, setRowSelection] = useState({}); const [hasInitialized, setHasInitialized] = useState(false); const [sorting, setSorting] = useState([ - { id: "position", desc: false }, + { id: "traffic", desc: true }, ]); const selectAnchorRef = useRef(null); @@ -188,17 +188,15 @@ export function KeywordSuggestionStep({ const data = suggestionsQuery.data ?? []; - // Pre-select top 20 by position once data loads + // Pre-select top 20 by traffic once data loads. useEffect(() => { const items = suggestionsQuery.data; if (items && items.length > 0 && !hasInitialized) { - // Data comes sorted by search volume from the API, but we display sorted - // by position. Pre-select the 20 with the best (lowest) positions. const indexed = items.map((item, i) => ({ index: i, - position: item.position ?? 999, + traffic: item.traffic ?? 0, })); - indexed.sort((a, b) => a.position - b.position); + indexed.sort((a, b) => b.traffic - a.traffic); const initial: RowSelectionState = {}; for (let i = 0; i < Math.min(PRE_SELECT_COUNT, indexed.length); i++) { initial[indexed[i].index] = true; diff --git a/src/routes/_project/p/$projectId/domain.tsx b/src/routes/_project/p/$projectId/domain.tsx index ed29dd3..416cf99 100644 --- a/src/routes/_project/p/$projectId/domain.tsx +++ b/src/routes/_project/p/$projectId/domain.tsx @@ -14,7 +14,7 @@ import { getDomainRouteState } from "@/client/features/domain/domainRouteState"; const DEFAULT_DOMAIN_SEARCH = { domain: "", subdomains: true, - sort: "rank", + sort: "traffic", order: undefined, tab: "keywords", loc: DEFAULT_LOCATION_CODE, diff --git a/src/server/features/domain/services/DomainService.ts b/src/server/features/domain/services/DomainService.ts index 757c09a..dc88ace 100644 --- a/src/server/features/domain/services/DomainService.ts +++ b/src/server/features/domain/services/DomainService.ts @@ -143,7 +143,7 @@ async function getSuggestedKeywords( locationCode: input.locationCode, languageCode: input.languageCode, limit: 100, - orderBy: ["keyword_data.keyword_info.search_volume,desc"], + orderBy: ["ranked_serp_element.serp_item.etv,desc"], }); const keywords = rankedKeywordsResponse.items diff --git a/src/types/schemas/domain.ts b/src/types/schemas/domain.ts index b13c420..1db4069 100644 --- a/src/types/schemas/domain.ts +++ b/src/types/schemas/domain.ts @@ -109,8 +109,8 @@ export const domainKeywordsPageRequestSchema = z.object({ (DOMAIN_KEYWORDS_PAGE_SIZES as readonly number[]).includes(value), ) .default(DEFAULT_DOMAIN_KEYWORDS_PAGE_SIZE), - sortMode: z.enum(domainSortModes).default("rank"), - sortOrder: z.enum(domainSortOrders).default("asc"), + sortMode: z.enum(domainSortModes).default("traffic"), + sortOrder: z.enum(domainSortOrders).default("desc"), filters: domainKeywordsFiltersSchema.default({}), search: z.string().optional(), });