Switch domain sorting defaults and rank-tracking suggestions to traffic (#223)
* Default domain keyword sorting to traffic * Align keyword suggestion preselection with traffic sort
This commit is contained in:
parent
d23b4eebfb
commit
f95c66b7f2
@ -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);
|
||||
}}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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(
|
||||
|
||||
@ -160,7 +160,7 @@ export function KeywordSuggestionStep({
|
||||
const [rowSelection, setRowSelection] = useState<RowSelectionState>({});
|
||||
const [hasInitialized, setHasInitialized] = useState(false);
|
||||
const [sorting, setSorting] = useState<SortingState>([
|
||||
{ id: "position", desc: false },
|
||||
{ id: "traffic", desc: true },
|
||||
]);
|
||||
const selectAnchorRef = useRef<SelectionAnchor | null>(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;
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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(),
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user