c80_estate 0.1.0.13 → 0.1.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/c80_estate/pstat.rb +90 -85
- data/lib/c80_estate/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75d267cd0efbe038362a4b5430a210bcae3b4b8d
|
4
|
+
data.tar.gz: ec12dcf5651824cf9aa505cf35bd03cbcbe07132
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 468937264e5b532ae8edf00bb6320f975eddacafb5e9787c730d4781fd96593936375ffb009c16522e097d7a1b59f27db038f72972a64912bc4a6322d67f80a5
|
7
|
+
data.tar.gz: bce7229fffd0536f1572596d1853a604a60e9c67954084e1ac6d9496ffa2d4ed294879725746f9a32d4d5bf609f120ea118e2a81609bf007a160855823990aa1
|
@@ -90,7 +90,7 @@ module C80Estate
|
|
90
90
|
result[:raw_props][:free_areas_count] = free_areas_atnow
|
91
91
|
result[:raw_props][:busy_areas_atnow] = busy_areas_atnow
|
92
92
|
result[:graph_dynamic] = _parse_for_js_dynamic_graph_canvasjs(pstats.ordered_by_created_at)
|
93
|
-
result[:graph_radial] = _parse_for_js_radial_graph(free_areas_atnow,busy_areas_atnow)
|
93
|
+
result[:graph_radial] = _parse_for_js_radial_graph(free_areas_atnow, busy_areas_atnow)
|
94
94
|
|
95
95
|
# Rails.logger.debug "<Pstat.busy_coef> busy_areas_count = #{ busy_areas_count }"
|
96
96
|
# Rails.logger.debug "<Pstat.busy_coef> all_areas_count = #{ all_areas_count }"
|
@@ -187,110 +187,115 @@ module C80Estate
|
|
187
187
|
# если в этот промежуток небыло событий - значит промежуток целиком попал в какое-то событие
|
188
188
|
# найдем его
|
189
189
|
# заодно поднимем вспомогательный флаг, который обработаем во view
|
190
|
-
mark_whole = false
|
190
|
+
# mark_whole = false
|
191
191
|
if pstats.count == 0
|
192
|
-
|
193
|
-
|
192
|
+
l = self.where(:property_id => prop_id).where("created_at < ?", used_start_date).last
|
193
|
+
if l.present?
|
194
|
+
pstats = [l]
|
195
|
+
# mark_whole = true
|
196
|
+
end
|
194
197
|
# sevents.each do |se|
|
195
198
|
# Rails.logger.debug "\t\t\t #{used_start_date - se.created_at}"
|
196
199
|
# end
|
197
200
|
end
|
198
201
|
|
199
202
|
# Занятость -----
|
203
|
+
if pstats.count > 0
|
204
|
+
|
205
|
+
# если сортируем по типу, то берём последнюю запись,
|
206
|
+
# иначе - берём последнюю запись с общими данными
|
207
|
+
if atype_id.nil?
|
208
|
+
free_areas_atnow = pstats.where(:atype_id => nil).last.free_areas
|
209
|
+
busy_areas_atnow = pstats.where(:atype_id => nil).last.busy_areas
|
210
|
+
graph_data = _parse_for_js_dynamic_graph_canvasjs(pstats.where(:atype_id => nil).ordered_by_created_at)
|
211
|
+
else
|
212
|
+
free_areas_atnow = pstats.last.free_areas
|
213
|
+
busy_areas_atnow = pstats.last.busy_areas
|
214
|
+
graph_data = _parse_for_js_dynamic_graph_canvasjs(pstats.ordered_by_created_at)
|
215
|
+
end
|
200
216
|
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
free_areas_atnow = pstats.where(:atype_id => nil).last.free_areas
|
205
|
-
busy_areas_atnow = pstats.where(:atype_id => nil).last.busy_areas
|
206
|
-
graph_data = _parse_for_js_dynamic_graph_canvasjs(pstats.where(:atype_id => nil).ordered_by_created_at)
|
207
|
-
else
|
208
|
-
free_areas_atnow = pstats.last.free_areas
|
209
|
-
busy_areas_atnow = pstats.last.busy_areas
|
210
|
-
graph_data = _parse_for_js_dynamic_graph_canvasjs(pstats.ordered_by_created_at)
|
211
|
-
end
|
212
|
-
|
213
|
-
# Rails.logger.debug("\t\t atype_id = #{atype_id}")
|
214
|
-
# Rails.logger.debug("\t\t free_areas_atnow = #{free_areas_atnow}")
|
215
|
-
# Rails.logger.debug("\t\t busy_areas_atnow = #{busy_areas_atnow}")
|
217
|
+
# Rails.logger.debug("\t\t atype_id = #{atype_id}")
|
218
|
+
# Rails.logger.debug("\t\t free_areas_atnow = #{free_areas_atnow}")
|
219
|
+
# Rails.logger.debug("\t\t busy_areas_atnow = #{busy_areas_atnow}")
|
216
220
|
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
221
|
+
# защищаемся от деления на ноль
|
222
|
+
if free_areas_atnow + busy_areas_atnow == 0
|
223
|
+
bcoef = 0.0
|
224
|
+
else
|
225
|
+
bcoef = busy_areas_atnow*1.0 / (free_areas_atnow + busy_areas_atnow) * 100.0
|
226
|
+
end
|
223
227
|
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
228
|
+
result[:busy_coef] = sprintf "%.2f%", bcoef
|
229
|
+
result[:comment] = "<abbr title='Период рассчёта занятости'>C #{used_start_date_str} по #{used_end_date_str}</abbr>"
|
230
|
+
result[:abbr] = 'Занятость объекта в конце указанного периода: число b/N, где b - кол-во свободных, N - всего площадей'
|
231
|
+
result[:graph_radial] = _parse_for_js_radial_graph(free_areas_atnow, busy_areas_atnow)
|
232
|
+
result[:graph_dynamic] = graph_data
|
229
233
|
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
+
result[:raw_props] = {}
|
235
|
+
result[:raw_props][:all_areas_count] = free_areas_atnow + busy_areas_atnow
|
236
|
+
result[:raw_props][:free_areas_count] = free_areas_atnow
|
237
|
+
result[:raw_props][:busy_areas_atnow] = busy_areas_atnow
|
234
238
|
|
235
|
-
|
239
|
+
# Занятость в метрах ------
|
236
240
|
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
241
|
+
if atype_id.nil?
|
242
|
+
free_areas_atnow_sq = pstats.where(:atype_id => nil).last.free_areas_sq
|
243
|
+
busy_areas_atnow_sq = pstats.where(:atype_id => nil).last.busy_areas_sq
|
244
|
+
graph_data_sq = _parse_for_js_dynamic_graph3_canvasjs(pstats.where(:atype_id => nil).ordered_by_created_at)
|
245
|
+
else
|
246
|
+
free_areas_atnow_sq = pstats.last.free_areas_sq
|
247
|
+
busy_areas_atnow_sq = pstats.last.busy_areas_sq
|
248
|
+
graph_data_sq = _parse_for_js_dynamic_graph3_canvasjs(pstats.ordered_by_created_at)
|
249
|
+
end
|
246
250
|
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
251
|
+
# защищаемся от деления на ноль
|
252
|
+
if busy_areas_atnow_sq + free_areas_atnow_sq == 0
|
253
|
+
bcoef_sq = 0.0
|
254
|
+
else
|
255
|
+
bcoef_sq = busy_areas_atnow_sq*1.0/(busy_areas_atnow_sq + free_areas_atnow_sq)*100.0
|
256
|
+
end
|
253
257
|
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
258
|
+
result[:busy_coef_sq] = sprintf "%.2f%", bcoef_sq
|
259
|
+
result[:comment_sq] = "<abbr title='Период рассчёта занятости в МЕТРАХ КВ'>C #{used_start_date_str} по #{used_end_date_str}</abbr>"
|
260
|
+
result[:abbr_sq] = 'Занятость объекта в МЕТРАХ в конце указанного периода: число b/N, где b - кол-во свободных МЕТРОВ, N - всего МЕТРОВ КВ'
|
261
|
+
result[:graph_dynamic_sq] = graph_data_sq
|
262
|
+
result[:graph_radial_sq] = _parse_for_js_radial_graph_sq(free_areas_atnow_sq, busy_areas_atnow_sq)
|
259
263
|
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
264
|
+
result[:props_sq] = [
|
265
|
+
{tag: 'all_areas_count_sq', val: "Кв.м. всего: #{busy_areas_atnow_sq + free_areas_atnow_sq}"},
|
266
|
+
{tag: 'free_areas_count_sq', val: "Свободных: #{free_areas_atnow_sq}"},
|
267
|
+
{tag: 'busy_areas_count_sq', val: "Занятых: #{busy_areas_atnow_sq}"}
|
268
|
+
]
|
265
269
|
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
+
result[:raw_props_sq] = {}
|
271
|
+
result[:raw_props_sq][:all_areas_count_sq] = free_areas_atnow_sq + busy_areas_atnow_sq
|
272
|
+
result[:raw_props_sq][:free_areas_count_sq] = free_areas_atnow_sq
|
273
|
+
result[:raw_props_sq][:busy_areas_atnow_sq] = busy_areas_atnow_sq
|
270
274
|
|
271
|
-
|
275
|
+
# common
|
272
276
|
|
273
|
-
|
274
|
-
|
277
|
+
result[:title] = "Статистика - Объект - #{property.title}"
|
278
|
+
# result[:graph] = _parse_for_js_radial_graph(free_areas_atnow,busy_areas_atnow)
|
275
279
|
|
276
280
|
|
277
|
-
|
278
|
-
|
279
|
-
|
281
|
+
# if atype_id.present?
|
282
|
+
# result[:title] += " (#{Atype.find(atype_id).title})"
|
283
|
+
# end
|
280
284
|
|
281
|
-
|
282
|
-
|
285
|
+
dc_str = property.areas.first.created_at.in_time_zone('Moscow').strftime('%Y/%m/%d')
|
286
|
+
dc_abbr = 'За дату создания объекта недвижимости при рассчетах берётся дата создания первой площади объекта'
|
283
287
|
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
288
|
+
result[:props] = [
|
289
|
+
{tag: 'title', val: "#{property.title}"},
|
290
|
+
{tag: 'born_date', val: "<abbr title='#{dc_abbr}'>Дата создания: #{dc_str}"},
|
291
|
+
{tag: 'all_areas_count', val: "<abbr title='В конце указанного периода'>Площадей всего</abbr>: #{ free_areas_atnow + busy_areas_atnow }"},
|
292
|
+
{tag: 'free_areas_count', val: "<abbr title='В конце указанного периода'>Свободных площадей</abbr>: #{ free_areas_atnow }"},
|
293
|
+
{tag: 'busy_areas_count', val: "<abbr title='В конце указанного периода'>Занятых площадей</abbr>: #{ busy_areas_atnow }"}
|
294
|
+
]
|
291
295
|
|
292
|
-
|
293
|
-
|
296
|
+
if atype_id.present?
|
297
|
+
result[:props] << {tag: 'atype_filter', val: "Фильтр по типу площади: #{ Atype.find(atype_id).title }"}
|
298
|
+
end
|
294
299
|
end
|
295
300
|
|
296
301
|
else
|
@@ -377,7 +382,7 @@ module C80Estate
|
|
377
382
|
result[:comment] = "<abbr title='Период рассчёта занятости'>C #{used_start_date_str} по #{used_end_date_str}</abbr>"
|
378
383
|
result[:abbr] = 'Занятость объекта в конце указанного периода: число b/N, где b - кол-во свободных, N - всего площадей'
|
379
384
|
result[:graph_dynamic] = _parse_for_js_dynamic_graph_canvasjs(pstats.ordered_by_created_at)
|
380
|
-
result[:graph_radial] = _parse_for_js_radial_graph(free_areas_atnow,busy_areas_atnow)
|
385
|
+
result[:graph_radial] = _parse_for_js_radial_graph(free_areas_atnow, busy_areas_atnow)
|
381
386
|
|
382
387
|
result[:raw_props] = {}
|
383
388
|
result[:raw_props][:all_areas_count] = free_areas_atnow + busy_areas_atnow
|
@@ -401,7 +406,7 @@ module C80Estate
|
|
401
406
|
result[:comment_sq] = "<abbr title='Период рассчёта занятости в МЕТРАХ КВ'>C #{used_start_date_str} по #{used_end_date_str}</abbr>"
|
402
407
|
result[:abbr_sq] = 'Занятость объекта в МЕТРАХ в конце указанного периода: число b/N, где b - кол-во свободных МЕТРОВ, N - всего МЕТРОВ КВ'
|
403
408
|
result[:graph_dynamic_sq] = graph_data_sq
|
404
|
-
result[:graph_radial_sq] = _parse_for_js_radial_graph_sq(free_areas_atnow_sq,busy_areas_atnow_sq)
|
409
|
+
result[:graph_radial_sq] = _parse_for_js_radial_graph_sq(free_areas_atnow_sq, busy_areas_atnow_sq)
|
405
410
|
|
406
411
|
result[:props_sq] = [
|
407
412
|
{tag: 'all_areas_count_sq', val: "Кв.м. всего: #{busy_areas_atnow_sq + free_areas_atnow_sq}"},
|
@@ -687,8 +692,8 @@ module C80Estate
|
|
687
692
|
end
|
688
693
|
end
|
689
694
|
{
|
690
|
-
sum_free_areas:sum_free_areas,
|
691
|
-
sum_busy_areas:sum_busy_areas
|
695
|
+
sum_free_areas: sum_free_areas,
|
696
|
+
sum_busy_areas: sum_busy_areas
|
692
697
|
}
|
693
698
|
end
|
694
699
|
|
data/lib/c80_estate/version.rb
CHANGED