revert: убрал SSE, вернул fetch + добавил skip/DELETE в extractor (v1.0.56)
This commit is contained in:
+21
-4
@@ -20,6 +20,18 @@
|
||||
<cfif sup.recordCount EQ 0>
|
||||
<cfset result.error = "supplement not found">
|
||||
<cfelse>
|
||||
<!--- Проверить: уже извлечено? --->
|
||||
<cfquery name="ex" datasource="baza">
|
||||
SELECT 1 FROM spec_rows WHERE supplement_id = <cfqueryparam value="#url.supplement_id#" cfsqltype="cf_sql_varchar"> LIMIT 1
|
||||
</cfquery>
|
||||
<cfif ex.recordCount GT 0>
|
||||
<cfquery name="cnt" datasource="baza">
|
||||
SELECT COUNT(*) as n FROM spec_rows WHERE supplement_id = <cfqueryparam value="#url.supplement_id#" cfsqltype="cf_sql_varchar">
|
||||
</cfquery>
|
||||
<cfset result = {ok: true, supplement_id: url.supplement_id, rows_saved: cnt.n, skipped: true}>
|
||||
<cfabort>
|
||||
</cfif>
|
||||
|
||||
<!--- textify: elements → текст --->
|
||||
<cfset elements = deserializeJSON(sup.elements_json)>
|
||||
<cfset textLines = []>
|
||||
@@ -136,11 +148,15 @@
|
||||
<cfset unresolved = extracted.unresolved>
|
||||
</cfif>
|
||||
|
||||
<!--- Сохраняем spec_rows --->
|
||||
<!--- Сохраняем spec_rows (DELETE + INSERT) --->
|
||||
<cfset savedRows = []>
|
||||
<cfloop array="#rows#" index="row">
|
||||
<cftry>
|
||||
<cfset rn = structKeyExists(row, 'row_num') ? row.row_num : 0>
|
||||
<cftransaction>
|
||||
<cfquery datasource="baza">
|
||||
DELETE FROM spec_rows WHERE supplement_id = <cfqueryparam value="#sup.id#" cfsqltype="cf_sql_varchar">
|
||||
</cfquery>
|
||||
<cfloop array="#rows#" index="row">
|
||||
<cftry>
|
||||
<cfset rn = structKeyExists(row, 'row_num') ? row.row_num : 0>
|
||||
<cfset nm = structKeyExists(row, 'name') ? row.name : ''>
|
||||
<cfset pr = (structKeyExists(row, 'price') AND len(row.price)) ? row.price : ''>
|
||||
<cfset qt = (structKeyExists(row, 'qty') AND len(row.qty)) ? row.qty : ''>
|
||||
@@ -165,6 +181,7 @@
|
||||
</cfcatch>
|
||||
</cftry>
|
||||
</cfloop>
|
||||
</cftransaction>
|
||||
|
||||
<cfset result = {
|
||||
ok: true,
|
||||
|
||||
Reference in New Issue
Block a user