feat: map market core user id to batch author uid
This commit is contained in:
parent
2e049ef718
commit
577f6bb0bd
@ -5,6 +5,7 @@ export interface BatchPayload {
|
||||
authors: Array<{
|
||||
authorId: string;
|
||||
authorName: string;
|
||||
authorUid?: string;
|
||||
}>;
|
||||
batchName: string;
|
||||
createdAt: string;
|
||||
@ -37,7 +38,8 @@ export function createBatchPayload(options: {
|
||||
return {
|
||||
authors: options.records.map((record) => ({
|
||||
authorId: record.authorId,
|
||||
authorName: record.authorName
|
||||
authorName: record.authorName,
|
||||
...(record.coreUserId ? { authorUid: record.coreUserId } : {})
|
||||
})),
|
||||
batchName,
|
||||
createdAt: options.createdAt,
|
||||
|
||||
@ -70,6 +70,7 @@ type RowOrderTarget = {
|
||||
type MarketDataRow = {
|
||||
authorId: string;
|
||||
authorName: string;
|
||||
coreUserId?: string;
|
||||
exportFields?: Record<string, string>;
|
||||
hasDirectRatesSource: boolean;
|
||||
location?: string;
|
||||
@ -1341,6 +1342,7 @@ function readSerializedMarketRows(
|
||||
return {
|
||||
authorId: readString(record.authorId) ?? "",
|
||||
authorName: readString(record.authorName) ?? "",
|
||||
coreUserId: readString(record.coreUserId) ?? undefined,
|
||||
exportFields: readSerializedExportFields(record),
|
||||
hasDirectRatesSource: Boolean(singleVideoAfterSearchRate),
|
||||
location: readString(record.location) ?? undefined,
|
||||
@ -1662,6 +1664,7 @@ function mergeMarketDataRows(
|
||||
return {
|
||||
authorId: preferredRow.authorId || baseRow.authorId,
|
||||
authorName: preferredRow.authorName || baseRow.authorName,
|
||||
coreUserId: mergeNonEmptyString(baseRow.coreUserId, preferredRow.coreUserId),
|
||||
exportFields: mergeExportFieldMaps(baseRow.exportFields, preferredRow.exportFields),
|
||||
hasDirectRatesSource:
|
||||
preferredRow.hasDirectRatesSource || baseRow.hasDirectRatesSource,
|
||||
|
||||
@ -222,6 +222,7 @@ function mergeMarketRecord(
|
||||
...existingRecord,
|
||||
...incomingRecord,
|
||||
authorName: mergeStringValue(existingRecord.authorName, incomingRecord.authorName) ?? "",
|
||||
coreUserId: mergeStringValue(existingRecord.coreUserId, incomingRecord.coreUserId),
|
||||
exportFields: mergeFieldMap(
|
||||
existingRecord.exportFields,
|
||||
incomingRecord.exportFields
|
||||
|
||||
@ -707,6 +707,10 @@ export function createMarketController(options: CreateMarketControllerOptions) {
|
||||
const existingRecord = resultStore.getRecord(rowSnapshot.authorId);
|
||||
const authorName =
|
||||
mergeStringValue(existingRecord?.authorName, rowSnapshot.authorName) ?? "";
|
||||
const coreUserId = mergeStringValue(
|
||||
existingRecord?.coreUserId,
|
||||
rowSnapshot.coreUserId
|
||||
);
|
||||
const location = mergeStringValue(existingRecord?.location, rowSnapshot.location);
|
||||
const price21To60s = mergeStringValue(
|
||||
existingRecord?.price21To60s,
|
||||
@ -721,6 +725,7 @@ export function createMarketController(options: CreateMarketControllerOptions) {
|
||||
rowSnapshot.backendMetrics
|
||||
),
|
||||
backendMetricsStatus: existingRecord?.backendMetricsStatus ?? "idle",
|
||||
coreUserId,
|
||||
exportFields: withExportFieldFallbacks(
|
||||
mergeFieldMap(existingRecord?.exportFields, rowSnapshot.exportFields),
|
||||
{
|
||||
|
||||
@ -57,6 +57,9 @@ export function mapMarketListRow(
|
||||
readString(readMarketFieldValue(row, attributeDatas, "nickname")) ??
|
||||
readString(readMarketFieldValue(row, attributeDatas, "nick_name")) ??
|
||||
"",
|
||||
coreUserId:
|
||||
readString(readMarketFieldValue(row, attributeDatas, "core_user_id")) ??
|
||||
undefined,
|
||||
exportFields: buildMarketExportFieldFallbacks(row, attributeDatas),
|
||||
hasDirectRatesSource: true,
|
||||
location: readMarketLocation(row, attributeDatas),
|
||||
|
||||
@ -205,6 +205,7 @@ function readSerializedMarketRows() {
|
||||
readString(row.star_id) ?? readString(attributeDatas.id) ?? "",
|
||||
authorName:
|
||||
readString(attributeDatas.nickname) ?? readString(row.nick_name) ?? "",
|
||||
coreUserId: readString(attributeDatas.core_user_id) ?? undefined,
|
||||
singleVideoAfterSearchRate
|
||||
};
|
||||
})
|
||||
|
||||
@ -61,6 +61,10 @@ export function createMarketResultStore() {
|
||||
existingRecord.authorName =
|
||||
mergeStringValue(existingRecord.authorName, row.authorName) ??
|
||||
existingRecord.authorName;
|
||||
existingRecord.coreUserId = mergeStringValue(
|
||||
existingRecord.coreUserId,
|
||||
row.coreUserId
|
||||
);
|
||||
existingRecord.location = mergeStringValue(
|
||||
existingRecord.location,
|
||||
row.location
|
||||
|
||||
@ -350,6 +350,7 @@ function mergeMarketRecord(
|
||||
...existingRecord,
|
||||
...incomingRecord,
|
||||
authorName: mergeStringValue(existingRecord.authorName, incomingRecord.authorName) ?? "",
|
||||
coreUserId: mergeStringValue(existingRecord.coreUserId, incomingRecord.coreUserId),
|
||||
exportFields: mergeFieldMap(
|
||||
existingRecord.exportFields,
|
||||
incomingRecord.exportFields
|
||||
|
||||
@ -22,6 +22,7 @@ export interface MarketRowSnapshot {
|
||||
authorId: string;
|
||||
authorName: string;
|
||||
backendMetrics?: BackendMetrics;
|
||||
coreUserId?: string;
|
||||
exportFields?: Record<string, string>;
|
||||
hasDirectRatesSource?: boolean;
|
||||
location?: string;
|
||||
|
||||
@ -1 +1 @@
|
||||
export const DEFAULT_BATCH_SUBMIT_BASE_URL = "http://192.168.31.21:8083";
|
||||
export const DEFAULT_BATCH_SUBMIT_BASE_URL = "http://localhost:8083";
|
||||
|
||||
@ -16,14 +16,19 @@ describe("batch-payload", () => {
|
||||
batchName: "618达人筛选第一批",
|
||||
createdAt: "2026-04-22T12:30:00.000Z",
|
||||
records: [
|
||||
{ authorId: "111", authorName: "达人A", status: "success" },
|
||||
{
|
||||
authorId: "111",
|
||||
authorName: "达人A",
|
||||
coreUserId: "core-111",
|
||||
status: "success"
|
||||
},
|
||||
{ authorId: "222", authorName: "达人B", status: "success" }
|
||||
]
|
||||
});
|
||||
|
||||
expect(payload).toEqual({
|
||||
authors: [
|
||||
{ authorId: "111", authorName: "达人A" },
|
||||
{ authorId: "111", authorName: "达人A", authorUid: "core-111" },
|
||||
{ authorId: "222", authorName: "达人B" }
|
||||
],
|
||||
batchName: "618达人筛选第一批",
|
||||
|
||||
@ -50,6 +50,7 @@ describe("silent-export-controller", () => {
|
||||
authors: [
|
||||
{
|
||||
attribute_datas: {
|
||||
core_user_id: `core-${pageNo}`,
|
||||
nickname: `达人${pageNo}`,
|
||||
price_20_60: pageNo * 1000
|
||||
},
|
||||
@ -93,6 +94,10 @@ describe("silent-export-controller", () => {
|
||||
}
|
||||
]);
|
||||
expect(records?.map((record) => record.authorId)).toEqual(["2", "3"]);
|
||||
expect(records?.map((record) => record.coreUserId)).toEqual([
|
||||
"core-2",
|
||||
"core-3"
|
||||
]);
|
||||
});
|
||||
|
||||
test("replays paged exports when the page number is nested inside the request body", async () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user