minor: изменения в замерах времени исполнения вьюшки
This commit is contained in:
@@ -14,12 +14,12 @@ def catalog_root(request: HttpRequest) -> HttpResponse:
|
||||
:param request: HttpRequest -- входящий http-запрос
|
||||
:return response: HttpResponse -- исходящий http-ответ
|
||||
"""
|
||||
time_start = time.time()
|
||||
time_start = time.perf_counter()
|
||||
# получаем из cookies последние визиты клиента
|
||||
to_template = {
|
||||
'LAST_VISIT': get_last_user_visit_list(get_last_user_visit_cookies(request)[:3]),
|
||||
'LOG_VISIT': get_last_all_user_visit_list(),
|
||||
'ticks': float(time.time() - time_start)}
|
||||
'ticks': float(time.perf_counter() - time_start)}
|
||||
response = render(request, "catalog/catalog_root.html", to_template)
|
||||
return response
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import pytils
|
||||
|
||||
|
||||
def catalog_company(request: HttpRequest) -> HttpResponse:
|
||||
time_start = time.time()
|
||||
time_start = time.perf_counter()
|
||||
to_template = {} # словарь, для передачи шаблону
|
||||
q_company = MerchantBrand.objects.raw('SELECT'
|
||||
' oknardia_merchantbrand.id,'
|
||||
@@ -65,13 +65,13 @@ def catalog_company(request: HttpRequest) -> HttpResponse:
|
||||
# получаем последние визиты всех посетителей из базы
|
||||
# id2log, log_visit = get_last_all_user_visit_list()
|
||||
'LOG_VISIT': get_last_all_user_visit_list(),
|
||||
'ticks': float(time.time() - time_start)
|
||||
'ticks': float(time.perf_counter() - time_start)
|
||||
})
|
||||
return render(request, "catalog/catalog_company.html", to_template)
|
||||
|
||||
|
||||
def catalog_company_detail(request: HttpRequest, company_id: str, company_name_slug: str) -> HttpResponse:
|
||||
time_start = time.time()
|
||||
time_start = time.perf_counter()
|
||||
to_template = {} # словарь, для передачи шаблону
|
||||
company_id = int(company_id)
|
||||
q_by_id = MerchantBrand.objects.get(id=company_id)
|
||||
@@ -156,6 +156,6 @@ def catalog_company_detail(request: HttpRequest, company_id: str, company_name_s
|
||||
# получаем последние визиты всех посетителей из базы
|
||||
# id2log, log_visit = get_last_all_user_visit_list()
|
||||
'LOG_VISIT': get_last_all_user_visit_list(),
|
||||
'ticks': float(time.time() - time_start)
|
||||
'ticks': float(time.perf_counter() - time_start)
|
||||
})
|
||||
return render(request, "catalog/catalog_company_detail.html", to_template)
|
||||
|
||||
@@ -11,7 +11,7 @@ import time
|
||||
import pytils
|
||||
|
||||
def standard_opening(request: HttpRequest) -> HttpResponse:
|
||||
time_start = time.time()
|
||||
time_start = time.perf_counter()
|
||||
to_template = {} # словарь, для передачи шаблону
|
||||
q_seria = Seria_Info.objects.raw('SELECT oknardia_seria_info.id, oknardia_seria_info.sName '
|
||||
'FROM oknardia_seria_info '
|
||||
@@ -76,7 +76,7 @@ def standard_opening(request: HttpRequest) -> HttpResponse:
|
||||
# получаем последние визиты всех посетителей из базы
|
||||
# id2log, log_visit = get_last_all_user_visit_list()
|
||||
'LOG_VISIT': get_last_all_user_visit_list(),
|
||||
'ticks': float(time.time() - time_start)
|
||||
'ticks': float(time.perf_counter() - time_start)
|
||||
})
|
||||
return render(request, "catalog/catalog_standard_opening.html", to_template)
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ def _append_visit_context(to_template: dict, request: HttpRequest, time_start: f
|
||||
to_template.update({
|
||||
'LAST_VISIT': get_last_user_visit_list(get_last_user_visit_cookies(request)[:3]),
|
||||
'LOG_VISIT': get_last_all_user_visit_list(),
|
||||
'ticks': float(time.time() - time_start),
|
||||
'ticks': float(time.perf_counter() - time_start),
|
||||
})
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ def catalog_profile(request: HttpRequest) -> HttpResponse:
|
||||
:param request: HttpRequest -- входящий http-запрос
|
||||
:return response: HttpResponse -- исходящий http-ответ
|
||||
"""
|
||||
time_start = time.time()
|
||||
time_start = time.perf_counter()
|
||||
# Берём только те поля, которые реально нужны для построения страницы каталога.
|
||||
# Это позволяет не тащить лишние данные из БД и сразу работать с простыми словарями.
|
||||
profile_rows = list(
|
||||
@@ -134,7 +134,7 @@ def catalog_profile_model(request: HttpRequest, manufacture_id: int, manufacture
|
||||
:param model_name: модель (марка) профиля (транслитерированное pytils.translit.slugify(sProfileName))
|
||||
:return response: HttpResponse -- исходящий http-ответ
|
||||
"""
|
||||
time_start = time.time()
|
||||
time_start = time.perf_counter()
|
||||
manufacture_id = int(manufacture_id)
|
||||
model_id = int(model_id)
|
||||
q_pvc_by_id = PVCprofiles.objects.get(id=model_id)
|
||||
@@ -269,7 +269,7 @@ def catalog_profile_manufacture(request: HttpRequest, manufacture_id: int, manuf
|
||||
:param manufacture_name: название производителя (транслитерированное pytils.translit.slugify())
|
||||
:return response: HttpResponse -- исходящий http-ответ
|
||||
"""
|
||||
time_start = time.time()
|
||||
time_start = time.perf_counter()
|
||||
manufacture_id = int(manufacture_id)
|
||||
q_pvc_by_id = PVCprofiles.objects.get(id=manufacture_id)
|
||||
if pytils.translit.slugify(q_pvc_by_id.sProfileManufacturer) != manufacture_name:
|
||||
|
||||
@@ -24,7 +24,7 @@ def catalog_seria(request: HttpRequest) -> HttpResponse:
|
||||
:param request: HttpRequest -- входящий http-запрос
|
||||
:return response: HttpResponse -- исходящий http-ответ
|
||||
"""
|
||||
time_start = time.time()
|
||||
time_start = time.perf_counter()
|
||||
try:
|
||||
q_seria = Seria_Info.objects.raw('SELECT'
|
||||
' oknardia_seria_info.id,'
|
||||
@@ -50,7 +50,7 @@ def catalog_seria(request: HttpRequest) -> HttpResponse:
|
||||
# получаем последние визиты всех посетителей из базы
|
||||
# id2log, log_visit = get_last_all_user_visit_list()
|
||||
'LOG_VISIT': get_last_all_user_visit_list(),
|
||||
'ticks': float(time.time() - time_start)
|
||||
'ticks': float(time.perf_counter() - time_start)
|
||||
})
|
||||
return render(request, "catalog/catalog_seria.html", to_template)
|
||||
|
||||
@@ -64,7 +64,7 @@ def catalog_seria_info(request: HttpRequest, seria_name_translit: None, seria_id
|
||||
:param seria_id: int -- id серии
|
||||
:return response: HttpResponse -- исходящий http-ответ
|
||||
"""
|
||||
time_start = time.time()
|
||||
time_start = time.perf_counter()
|
||||
msg = ""
|
||||
try:
|
||||
seria_id = int(seria_id)
|
||||
@@ -113,7 +113,7 @@ def catalog_seria_info(request: HttpRequest, seria_name_translit: None, seria_id
|
||||
# print StringForSqlIN
|
||||
# Получаем данные для таблички Окон по типам квартирах в серии дома
|
||||
# " IFNULL(oknardia_mountdim2apartment.iQuantity, 0) AS iQuantity," \
|
||||
# tStart2 = time.time() # замер времени
|
||||
# tStart2 = time.perf_counter() # замер времени
|
||||
q_win_in_apartment_in_seria = Win_MountDim.objects.raw(
|
||||
f"SELECT"
|
||||
f" oknardia_win_mountdim.id,"
|
||||
@@ -186,7 +186,7 @@ def catalog_seria_info(request: HttpRequest, seria_name_translit: None, seria_id
|
||||
min_offer_in_row = 10000
|
||||
row_for_table = []
|
||||
# print(table_of_win_in_seria_by_apartmment)
|
||||
# print(f"==============>{float(time.time()-tStart2)}<==============")
|
||||
# print(f"==============>{float(time.perf_counter()-tStart2)}<==============")
|
||||
# print NumOffersPerColumn, NumMerchantPerColumn
|
||||
to_template.update({"WIN_OFFER_AND_MERCHANT": offer_and_merchant_per_win,
|
||||
"TABLE_OF_WINDOWS": table_of_win_in_seria_by_apartmment})
|
||||
@@ -210,14 +210,14 @@ def catalog_seria_info(request: HttpRequest, seria_name_translit: None, seria_id
|
||||
to_template.update({'THIS_SERIA_NAME': seria_name})
|
||||
|
||||
# to_template.update({'LOG_VISIT': GetLastAllUserVisitSeriaList(SeriaName),
|
||||
# 'ticks': float(time.time()-time_start)})
|
||||
# 'ticks': float(time.perf_counter()-time_start)})
|
||||
to_template.update({
|
||||
# получаем последние визиты клиента через куки
|
||||
'LAST_VISIT': get_last_user_visit_list(get_last_user_visit_cookies(request)[:3]),
|
||||
# получаем последние визиты всех посетителей из базы
|
||||
# id2log, log_visit = get_last_all_user_visit_list()
|
||||
'LOG_VISIT': get_last_all_user_visit_list(),
|
||||
'ticks': float(time.time() - time_start)
|
||||
'ticks': float(time.perf_counter() - time_start)
|
||||
})
|
||||
return render(request, light_template, to_template)
|
||||
|
||||
|
||||
@@ -325,7 +325,7 @@ def report_one_win_price(request: HttpRequest, win_width_mm: str = '670', win_he
|
||||
:param win_id: str -- ID проема (см. таблицу oknardia_win_mountdim)
|
||||
:return response: HttpResponse -- исходящий http-ответ
|
||||
"""
|
||||
time_start = time.time()
|
||||
time_start = time.perf_counter()
|
||||
to_template = {}
|
||||
try:
|
||||
# т.к. для вызова GetFlapDim4BigPictures нужно иметь внутри queryset поле iQuantity нельзя использовать
|
||||
@@ -439,7 +439,7 @@ def report_one_win_price(request: HttpRequest, win_width_mm: str = '670', win_he
|
||||
# получаем последние визиты всех посетителей из базы
|
||||
# id2log, log_visit = get_last_all_user_visit_list()
|
||||
'LOG_VISIT': get_last_all_user_visit_list(),
|
||||
'ticks': float(time.time() - time_start)
|
||||
'ticks': float(time.perf_counter() - time_start)
|
||||
})
|
||||
return render(request, "price/price_offers_for_one_window.html", to_template)
|
||||
|
||||
@@ -452,11 +452,11 @@ def next_one_win_price(request: HttpRequest, win_id='16', frame_begin_n="0"):
|
||||
:param frame_begin_n: str -- Номер записи с которой начинается фрейм с ценами
|
||||
:return: HttpResponse --
|
||||
"""
|
||||
time_start = time.time()
|
||||
time_start = time.perf_counter()
|
||||
to_template = report_price_frame(0, 1, 0, 0, int(frame_begin_n), 0, int(win_id))
|
||||
to_template.update({'MOUNT_DIM_PER_OFFER': 1,
|
||||
'WIN_ID': int(win_id),
|
||||
'ticks': float(time.time() - time_start)})
|
||||
'ticks': float(time.perf_counter() - time_start)})
|
||||
return render(request, "price/price_offers_for_one_window_frame.html", to_template)
|
||||
|
||||
|
||||
@@ -470,7 +470,7 @@ def report_price(request: HttpRequest, build_id: str = "22427", apart_id: str =
|
||||
:param slug: str - slug адреса здания
|
||||
:return: response: HttpResponse
|
||||
"""
|
||||
time_start = time.time()
|
||||
time_start = time.perf_counter()
|
||||
msg = ""
|
||||
to_template = {}
|
||||
try:
|
||||
@@ -657,14 +657,14 @@ def report_price(request: HttpRequest, build_id: str = "22427", apart_id: str =
|
||||
log_entry.sLogAddress = to_template["ADDRESS"]
|
||||
log_entry.sLogNameApartment = to_template["APART"]
|
||||
log_entry.sLogURL = f"/{build_id}/{apart_id}/{to_template['ADDRESS_T']}"
|
||||
log_entry.dLogVisitTime = time.time()
|
||||
log_entry.dLogVisitTime = time.perf_counter()
|
||||
log_entry.save() # UPDATE
|
||||
except ObjectDoesNotExist:
|
||||
log_entry = LogVisitPriceReport(
|
||||
sLogAddress=to_template["ADDRESS"],
|
||||
sLogNameApartment=to_template["APART"],
|
||||
sLogURL=f"/{build_id}/{apart_id}/{to_template['ADDRESS_T']}",
|
||||
dLogVisitTime=time.time()
|
||||
dLogVisitTime=time.perf_counter()
|
||||
)
|
||||
log_entry.save() # INSERT
|
||||
|
||||
@@ -676,11 +676,11 @@ def report_price(request: HttpRequest, build_id: str = "22427", apart_id: str =
|
||||
"LastURL": f"/{build_id}/{apart_id}/{to_template['ADDRESS_T']}",
|
||||
"LastAddress": to_template["ADDRESS"],
|
||||
"LastApart": to_template["APART"],
|
||||
"Time": time.time()}
|
||||
"Time": time.perf_counter()}
|
||||
last_visit.insert(0, Item) # Добавляем текущий Item в начало
|
||||
last_visit = json.dumps(last_visit[:3]) # упаковываем json без пробелов (три записи)
|
||||
# print u"сейчас запишем вот эту куку:", LastVisit
|
||||
to_template.update({'ticks': float(time.time() - time_start)})
|
||||
to_template.update({'ticks': float(time.perf_counter() - time_start)})
|
||||
response = render(request, "price/price_list.html", to_template)
|
||||
response.set_cookie("LastVisit", last_visit, max_age=7862400) # ставим или перезаписываем куки (91 день)
|
||||
return response
|
||||
@@ -702,7 +702,7 @@ def next_price_frame(request: HttpRequest, apart_id: str = "1", mount_dim_per_o
|
||||
:param frame_begin_n: str -- Номер записи с которой начинается фрейм с ценами
|
||||
:return: HttpResponse -- HTTP-ответ
|
||||
"""
|
||||
time_start = time.time()
|
||||
time_start = time.perf_counter()
|
||||
# получаем данные для фрейма ценовых предложений
|
||||
price_frame = report_price_frame(int(apart_id), int(mount_dim_per_offer), float(address_longitude),
|
||||
float(address_latitude), int(frame_begin_n))
|
||||
@@ -711,5 +711,5 @@ def next_price_frame(request: HttpRequest, apart_id: str = "1", mount_dim_per_o
|
||||
'MOUNT_DIM_PER_OFFER': mount_dim_per_offer,
|
||||
'ADDRESS_LAT': address_latitude,
|
||||
'ADDRESS_LON': address_longitude,
|
||||
'ticks': float(time.time() - time_start)})
|
||||
'ticks': float(time.perf_counter() - time_start)})
|
||||
return render(request, "price/price_list_frame.html", to_template)
|
||||
|
||||
@@ -80,7 +80,7 @@ def compare_offers(request: HttpRequest, to_compare: str = "1,2") -> HttpRespons
|
||||
:param to_compare: str -- список ,через запятую, id оконных наборов (Set) для сравнения
|
||||
:return: HttpResponse --
|
||||
"""
|
||||
time_start = time.time()
|
||||
time_start = time.perf_counter()
|
||||
to_template = {}
|
||||
try:
|
||||
# Этот блок нужен для 302-переадресации, когда разные URL отдают одинаковые страницы.
|
||||
@@ -539,7 +539,7 @@ def compare_offers(request: HttpRequest, to_compare: str = "1,2") -> HttpRespons
|
||||
# получаем последние визиты всех посетителей из базы
|
||||
# id2log, log_visit = get_last_all_user_visit_list()
|
||||
'LOG_VISIT': get_last_all_user_visit_list(),
|
||||
'ticks': float(time.time() - time_start)
|
||||
'ticks': float(time.perf_counter() - time_start)
|
||||
})
|
||||
return render(request, "report/report_compare_set.html", to_template)
|
||||
|
||||
@@ -551,7 +551,7 @@ def show_rating_components(request: HttpRequest, win_set: str = "1") -> HttpResp
|
||||
:param win_set: str -- id оконного набора, для которого показать состав рейтинга
|
||||
:return: HttpResponse --
|
||||
"""
|
||||
time_start = time.time()
|
||||
time_start = time.perf_counter()
|
||||
to_template = {}
|
||||
try:
|
||||
win_set = int(win_set)
|
||||
@@ -596,5 +596,5 @@ def show_rating_components(request: HttpRequest, win_set: str = "1") -> HttpResp
|
||||
"коммерческое предложение, коммерческих предложения,"
|
||||
" коммерческих предложений"),
|
||||
'TEST': win_set,
|
||||
'ticks': float(time.time() - time_start)})
|
||||
'ticks': float(time.perf_counter() - time_start)})
|
||||
return render(request, "report/show_rating_components.html", to_template)
|
||||
|
||||
@@ -16,18 +16,18 @@ def service(request: HttpRequest) -> HttpResponse:
|
||||
:param request: HttpRequest
|
||||
:return: HttpResponse
|
||||
"""
|
||||
time_start = time.time()
|
||||
time_start = time.perf_counter()
|
||||
# проверка на аутентификацию
|
||||
# print(request.user.is_authenticated)
|
||||
if not request.user.is_authenticated:
|
||||
return redirect("/service/not-denice")
|
||||
return render(request, "service/index.html", {'ticks': float(time.time()-time_start)})
|
||||
return render(request, "service/index.html", {'ticks': float(time.perf_counter()-time_start)})
|
||||
|
||||
|
||||
# страничка, на которую переадресует служебный интерфейс, если нет аутентификации.
|
||||
def not_denice(request):
|
||||
time_start = time.time()
|
||||
return render(request, "service/not_denice.html", {'ticks': float(time.time()-time_start)})
|
||||
time_start = time.perf_counter()
|
||||
return render(request, "service/not_denice.html", {'ticks': float(time.perf_counter()-time_start)})
|
||||
|
||||
|
||||
def tmp(request: HttpRequest) -> HttpResponse:
|
||||
@@ -36,8 +36,8 @@ def tmp(request: HttpRequest) -> HttpResponse:
|
||||
:param request:
|
||||
:return:
|
||||
"""
|
||||
t_start = time.time()
|
||||
return render(request, "service/tmp.html", {'TAU': float(time.time()-t_start)})
|
||||
t_start = time.perf_counter()
|
||||
return render(request, "service/tmp.html", {'TAU': float(time.perf_counter()-t_start)})
|
||||
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ def make_rating(request: HttpRequest) -> HttpResponse:
|
||||
:param request: HttpRequest -- запрос
|
||||
:return: HttpResponse -- ответ
|
||||
"""
|
||||
time_start = time.time()
|
||||
time_start = time.perf_counter()
|
||||
msg = ""
|
||||
# ВЫЧИСЛЯЕМ РЕЙТИНГ ПРОФИЛЕЙ
|
||||
# устанавливаем рейтинг всех профилей в базе в ноль
|
||||
@@ -364,5 +364,5 @@ def make_rating(request: HttpRequest) -> HttpResponse:
|
||||
obj.save()
|
||||
# print u"id:",i["id"], u"\tRank:", i["TmpRating"], u"\tRate:", obj.fSetRating, u"\tSet:", i["sSetName"], i["fProfileRating"], i["fGlazingRating"]
|
||||
to_template.update({'msg': msg})
|
||||
to_template.update({'ticks': float(time.time()-time_start)})
|
||||
to_template.update({'ticks': float(time.perf_counter()-time_start)})
|
||||
return render(request, "service/make_rating.html", to_template)
|
||||
@@ -113,7 +113,7 @@ def get_address(request: HttpRequest) -> HttpResponse:
|
||||
:param request: request
|
||||
:return: response
|
||||
░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░"""
|
||||
time_start = time.time()
|
||||
time_start = time.perf_counter()
|
||||
if request.method != 'POST':
|
||||
return redirect("/")
|
||||
if 'address' not in request.POST:
|
||||
@@ -149,7 +149,7 @@ def get_address(request: HttpRequest) -> HttpResponse:
|
||||
f"ORDER BY R2 "
|
||||
f"LIMIT 1;")[0]
|
||||
if q.R2 > 0.67: # Если расстояние между точками больше 670 метров, то не показываем результат
|
||||
to_template.update({'ticks': float(time.time()-time_start)})
|
||||
to_template.update({'ticks': float(time.perf_counter()-time_start)})
|
||||
to_template.update({'addr': addr})
|
||||
return render(request, "popup/popup_incorrect_address.html", to_template)
|
||||
addr = q.sAddress
|
||||
@@ -292,5 +292,5 @@ def get_address(request: HttpRequest) -> HttpResponse:
|
||||
to_template.update({'SERIA_BASE': q1.sName,
|
||||
'addr': addr,
|
||||
'addr_T': pytils.translit.slugify(addr),
|
||||
'ticks': float(time.time()-time_start)})
|
||||
'ticks': float(time.perf_counter()-time_start)})
|
||||
return render(request, "popup/popup_show_apartment_variants.html", to_template)
|
||||
|
||||
Reference in New Issue
Block a user