1- import { extractNodePropertiesFromRecords , extractNodeAndRelPropertiesFromRecords } from './ReportRecordProcessing' ;
21import isEqual from 'lodash.isequal' ;
2+ import { extractNodeAndRelPropertiesFromRecords , extractNodePropertiesFromRecords } from './ReportRecordProcessing' ;
33
44export enum QueryStatus {
55 NO_QUERY , // No query specified
@@ -66,8 +66,9 @@ export async function runCypherQuery(
6666 return ;
6767 }
6868
69+ // we need to ensure the databse ame is set
6970 const session = database ? driver . session ( { database : database } ) : driver . session ( ) ;
70- const transaction = session . beginTransaction ( { timeout : queryTimeLimit * 1000 , connectionTimeout : 2000 } ) ;
71+ // const transaction = session.beginTransaction({ timeout: queryTimeLimit * 1000, connectionTimeout: 2000 });
7172
7273 // For usuability reasons, we can set a hard cap on the query result size by wrapping it a subquery (Neo4j 4.0 and later).
7374 // This unfortunately does not preserve ordering on the return fields.
@@ -79,17 +80,18 @@ export async function runCypherQuery(
7980 query = `CALL { ${ query } } RETURN * LIMIT ${ rowLimit + 1 } ` ;
8081 }
8182 }
83+ // we use async iteratiors in workspace to archieve this, pro tip!
8284
83- await transaction
84- . run ( query , parameters )
85+ await session
86+ // TODO seems the timeout doesn't work poreoprly eitehr
87+ . run ( query , parameters ) // , { timeout: queryTimeLimit * 1000, connectionTimeout: 2000 })
8588 . then ( ( res ) => {
8689 // @ts -ignore
8790 const { records } = res ;
8891 // TODO - check query summary to ensure that no writes are made in safe-mode.
8992 if ( records . length == 0 ) {
9093 setStatus ( QueryStatus . NO_DATA ) ;
9194 // console.log("TODO remove this - QUERY RETURNED NO DATA!")
92- transaction . commit ( ) ;
9395 return ;
9496 }
9597
@@ -111,20 +113,16 @@ export async function runCypherQuery(
111113 if ( records == null ) {
112114 setStatus ( QueryStatus . NO_DRAWABLE_DATA ) ;
113115 // console.log("TODO remove this - QUERY RETURNED NO DRAWABLE DATA!")
114- transaction . commit ( ) ;
115116 return ;
116117 } else if ( records . length > rowLimit ) {
117118 setStatus ( QueryStatus . COMPLETE_TRUNCATED ) ;
118119 setRecords ( records . slice ( 0 , rowLimit ) ) ;
119120 // console.log("TODO remove this - QUERY RETURNED WAS TRUNCTURED!")
120- transaction . commit ( ) ;
121121 return ;
122122 }
123123 setStatus ( QueryStatus . COMPLETE ) ;
124124 setRecords ( records ) ;
125125 // console.log("TODO remove this - QUERY WAS EXECUTED SUCCESFULLY!")
126-
127- transaction . commit ( ) ;
128126 } )
129127 . catch ( ( e ) => {
130128 // setFields([]);
@@ -139,7 +137,6 @@ export async function runCypherQuery(
139137 ) {
140138 setStatus ( QueryStatus . TIMED_OUT ) ;
141139 setRecords ( [ { error : e . message } ] ) ;
142- transaction . rollback ( ) ;
143140 return e . message ;
144141 }
145142
@@ -148,7 +145,6 @@ export async function runCypherQuery(
148145 if ( setRecords ) {
149146 setRecords ( [ { error : e . message } ] ) ;
150147 }
151- transaction . rollback ( ) ;
152148 return e . message ;
153149 } ) ;
154150}
0 commit comments