@@ -153,22 +153,58 @@ const session = driver.session();
153
153
154
154
155
155
let schema = [
156
+ //PROFILE
157
+ `WITH [] AS area, [
158
+ 'POLYGON((37.036529609374995 56.03991134977714,38.220306464843716 56.03991134977714,38.220306464843716 55.404346266130695,37.036529609374995 55.404346266130695,37.036529609374995 56.03991134977714))',
159
+ 'POLYGON((37.036529609374995 56.03991134977714,38.220306464843716 56.03991134977714,38.220306464843716 55.404346266130695,37.036529609374995 55.404346266130695,37.036529609374995 56.03991134977714))'
160
+ ] AS poly
161
+ UNWIND poly AS p
162
+ CALL custom.polygon5(p) YIELD buildings
163
+ WITH area + COLLECT(DISTINCT buildings) AS area
164
+
165
+ CALL custom.polygon5('POLYGON((37.036529609374995 56.03991134977714,38.220306464843716 56.03991134977714,38.220306464843716 55.404346266130695,37.036529609374995 55.404346266130695,37.036529609374995 56.03991134977714))') YIELD buildings
166
+ WITH area, COLLECT(DISTINCT buildings) AS viewport
167
+
168
+ WITH apoc.coll.intersection(viewport, area) AS intersect
169
+
170
+ CALL apoc.nodes.get(intersect) YIELD node AS building
171
+ WITH intersect, building LIMIT 2000 WHERE building.operation_year < 2023
172
+
173
+ MATCH (building)<--(l :Лот)-[:тип]->(nt:\`Тип недвижимости\`)
174
+ WHERE
175
+ l.price > 5000000 AND l.price < 10000000
176
+ AND l.square > 10 AND l.square < 100
177
+ WITH DISTINCT building LIMIT 20
178
+
179
+ MATCH (building)<--(l :Лот)-[:тип]->(nt:\`Тип недвижимости\`)
180
+ WHERE
181
+ l.price > 5000000 AND l.price < 10000000
182
+ AND l.square > 10 AND l.square < 100
183
+
184
+ WITH building {.*, lots: {type: nt.name, rooms: l.rooms, count: COUNT(l), price: { min: MIN(l.price), max: MAX(l.price) }, square: { min: MIN(l.square), max: MAX(l.square)} } } //SKIP 80 LIMIT 20
185
+
186
+ //WITH SIZE(intersect) AS area
187
+
188
+ RETURN *` ,
156
189
'CREATE INDEX ON :Адрес(name)' ,
157
190
'CREATE INDEX ON :Девелопер(name)' ,
158
191
'CREATE INDEX ON :Застройщик(name)' ,
159
192
'CREATE INDEX ON :Класс(name)' ,
160
193
'CREATE INDEX ON :Конструктив(name)' ,
161
194
'CREATE INDEX ON :Корпус(id)' ,
195
+ 'CREATE INDEX ON :Корпус(operation_year)' ,
196
+ 'CREATE INDEX ON :Корпус(operation_quarter)' ,
162
197
'CREATE INDEX ON :Лот(id)' ,
163
198
'CREATE INDEX ON :Лот(price)' ,
199
+ 'CREATE INDEX ON :Лот(square)' ,
164
200
'CREATE INDEX ON :Отделка(name)' ,
165
201
'CREATE INDEX ON :Проект(name)' ,
166
202
'CREATE INDEX ON :Стадия(name)' ,
167
203
'CREATE INDEX ON :`Тип парковки`(name)' ,
168
204
'CREATE INDEX ON :`Тип недвижимости`(name)' ,
169
205
'CREATE INDEX ON :`Тип фото`(name)' ,
170
206
'CREATE INDEX ON :Фото(url)' ,
171
- // 'CALL spatial.removeLayer("geom")',
207
+ 'CALL spatial.removeLayer("geom")' ,
172
208
'CALL spatial.addPointLayer("geom")'
173
209
]
174
210
@@ -189,7 +225,13 @@ promise.then(async result => {
189
225
session . close ( ) ;
190
226
191
227
for ( let i = 0 ; i < schema . length ; i ++ ) {
192
- await session . run ( schema [ i ] ) ;
228
+ try {
229
+ console . time ( 'try' ) ;
230
+ await session . run ( schema [ i ] ) ;
231
+ console . timeEnd ( 'try' ) ;
232
+ console . log ( schema [ i ] ) ;
233
+ }
234
+ catch ( err ) { }
193
235
}
194
236
195
237
const singleRecord = result . records [ 0 ] ;
@@ -210,7 +252,7 @@ promise.then(async result => {
210
252
await Promise . all ( queries ) ;
211
253
queries = [ ] ;
212
254
213
- let part = ids . splice ( 0 , 20 ) ;
255
+ let part = ids . splice ( 0 , 10 ) ;
214
256
let i = part . length - 1 ;
215
257
216
258
@@ -230,12 +272,16 @@ promise.then(async result => {
230
272
} )
231
273
. then ( result => {
232
274
let building = result . data ;
275
+ //building.id = building.id + '';
233
276
234
277
const session = driver . session ( ) ;
235
278
const promise = session . run (
236
279
`WITH {building} as building
237
280
238
- MERGE (b :Корпус {id: building.id}) SET b += building {.commercial_square, .total_square, .pantry_count, .created_at, .floors_num, .parking_spaces_count, .discounts, .updated_at, .parking_available, .floors_from, .pantry_available, .construction_start, .floors_to, .in_operation_date, .sales_start, .name, .living_square, .ceiling_height, .building_type}
281
+ MERGE (b :Корпус {id: building.id}) SET b += building {.commercial_square, .total_square, .pantry_count, .created_at, .floors_num,
282
+ .parking_spaces_count, .discounts, .updated_at, .parking_available, .floors_from, .pantry_available, .construction_start,
283
+ .floors_to, .in_operation_date, .sales_start, .name, .living_square, .ceiling_height, .building_type,
284
+ operation_year: date(building.in_operation_date).year, operation_quarter: date(building.in_operation_date).quarter}
239
285
240
286
MERGE (cs :Стадия {name: COALESCE(building.construction_stage.name, 'Не указано')}) SET cs += COALESCE(building.construction_stage, {})
241
287
MERGE (pt :\`Тип парковки\` {name: COALESCE(building.parking_type.name, 'Не указано')}) SET pt += COALESCE(building.parking_type, {})
0 commit comments