@@ -12,13 +12,12 @@ export type JobInput = {
1212 url : string
1313 postedAt ?: Date | string
1414 description ?: string
15- isRemote ?: boolean
15+ isRemote ?: boolean | null
1616 tags ?: string [ ]
1717 metadata ?: Record < string , string >
1818 source : {
1919 name : string
2020 externalId ?: string
21- rawUrl ?: string
2221 data ?: any
2322 }
2423}
@@ -46,7 +45,11 @@ export async function upsertJob(input: JobInput) {
4645 location : input . location ,
4746 postedAt : input . postedAt ? new Date ( input . postedAt ) : undefined ,
4847 description : input . description ,
49- isRemote : input . isRemote ,
48+ isRemote : input . isRemote ?? undefined ,
49+ // Write source-related fields directly on Job
50+ source : input . source ?. name ,
51+ externalId : input . source ?. externalId ,
52+ data : input . source ?. data as any ,
5053 company : companyRecord ? { connect : { id : companyRecord . id } } : undefined ,
5154 updatedAt : new Date ( ) ,
5255 } ,
@@ -56,8 +59,12 @@ export async function upsertJob(input: JobInput) {
5659 location : input . location ,
5760 postedAt : input . postedAt ? new Date ( input . postedAt ) : undefined ,
5861 description : input . description ,
59- isRemote : input . isRemote ,
62+ isRemote : input . isRemote ?? undefined ,
6063 url : input . url ,
64+ // Write source-related fields directly on Job
65+ source : input . source ?. name ,
66+ externalId : input . source ?. externalId ,
67+ data : input . source ?. data as any ,
6168 company : companyRecord ? { connect : { id : companyRecord . id } } : undefined ,
6269 } ,
6370 } )
@@ -90,27 +97,5 @@ export async function upsertJob(input: JobInput) {
9097 }
9198 }
9299
93- // Upsert job source (also requires a compound unique constraint for source + externalId)
94- await prisma . jobSource . upsert ( {
95- where : {
96- source_externalId : {
97- source : input . source . name ,
98- externalId : input . source . externalId || '' ,
99- } ,
100- } ,
101- update : {
102- rawUrl : input . source . rawUrl ,
103- data : input . source . data ,
104- jobId : job . id ,
105- } ,
106- create : {
107- source : input . source . name ,
108- externalId : input . source . externalId ,
109- rawUrl : input . source . rawUrl ,
110- data : input . source . data ,
111- jobId : job . id ,
112- } ,
113- } )
114-
115100 return job
116101}
0 commit comments