Skip to content

Commit

Permalink
update static middlewares code
Browse files Browse the repository at this point in the history
  • Loading branch information
bluebamus committed Aug 27, 2024
1 parent 148156c commit 9fc1f0c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 21 deletions.
Binary file modified config/locale/ko/LC_MESSAGES/django.mo
Binary file not shown.
6 changes: 3 additions & 3 deletions config/locale/ko/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -827,8 +827,8 @@ msgid "fast-api"
msgstr ""

#: .\templates\home\index.html:140
msgid "A Python server suitable for microservices based on Message Queue."
msgstr "Message Queue 기반의 마이크로서비스에 적합한 Python 서버"
msgid "A Python server suitable for microservices based on Rest API."
msgstr "Rest API 기반의 마이크로서비스에 적합한 Python 서버"

#: .\templates\home\index.html:148
msgid "vue.js"
Expand All @@ -845,7 +845,7 @@ msgstr "Redis 고급"
#: .\templates\home\index.html:158
msgid ""
"Implementation of RDB, AOF, Sharding, Consistent Hashing, and Redis Cluster."
msgstr "RDB, AOF, Sharding, Consistent Hashing, Redis Cluster 구현하기"
msgstr "RDB, AOF, Sharding, Consistent Hashing, Redis Cluster 구축하기"

#: .\templates\home\index.html:166
msgid "RabbitMQ Advanced"
Expand Down
44 changes: 27 additions & 17 deletions custom_middlewares/common/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,30 @@ def __init__(self, get_response):
self.get_response = get_response

def stats(self, os_info):
today = timezone.now().date()
with transaction.atomic():
count = ConnectionMethodStats.objects.filter(
created_at__day=timezone.now().date().day
# count = ConnectionMethodStats.objects.filter(
# created_at__day=timezone.now().date().day
# )
# if not count:
# ConnectionMethodStats.objects.create(created_at=timezone.now())

stats, created = ConnectionMethodStats.objects.get_or_create(
created_at__date=today
)
if not count:
ConnectionMethodStats.objects.create(created_at=timezone.now())

if "Windows" in os_info:
count.update(win=F("win") + 1)
stats.win = F("win") + 1
elif "mac" in os_info:
count.update(mac=F("mac") + 1)
stats.mac = F("mac") + 1
elif "iPhone" in os_info:
count.update(iph=F("iph") + 1)
stats.iph = F("iph") + 1
elif "Android" in os_info:
count.update(android=F("android") + 1)
stats.android = F("android") + 1
else:
count.update(oth=F("oth") + 1)
stats.oth = F("oth") + 1

stats.save() # 변경 사항 저장

def __call__(self, request):
if "HTTP_USER_AGENT" in request.META:
Expand All @@ -50,20 +57,23 @@ def __init__(self, get_response):
def __call__(self, request):
if "admin" not in request.path:
with transaction.atomic():
count = ConnectionHardwareStats.objects.filter(
created_at__day=timezone.now().date().day
today = timezone.now().date()
# 오늘 날짜의 통계 가져오기
stats, created = ConnectionHardwareStats.objects.get_or_create(
created_at__date=today
)
if not count:
ConnectionHardwareStats.objects.create(created_at=timezone.now())

# 사용자 에이전트에 따라 카운트 업데이트
if request.user_agent.is_mobile:
count.update(mobile=F("mobile") + 1)
stats.mobile = F("mobile") + 1
elif request.user_agent.is_tablet:
count.update(tablet=F("tablet") + 1)
stats.tablet = F("tablet") + 1
elif request.user_agent.is_pc:
count.update(pc=F("pc") + 1)
stats.pc = F("pc") + 1
elif request.user_agent.is_bot:
count.update(bot=F("bot") + 1)
stats.bot = F("bot") + 1

stats.save() # 변경 사항 저장

response = self.get_response(request)

Expand Down
Binary file added static/images/4_bigdata_back.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion templates/home/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ <h2 class="mb-4"> {% trans "What I am studying, the project I am planning" %}</h
<div class="icon d-flex align-items-center justify-content-center"><span class="flaticon-branding"></span></div>
<div class="media-body">
<h3 class="heading mb-3">{% trans "fast-api"%} </h3>
<p> {% trans "A Python server suitable for microservices based on Message Queue." %}</p>
<p> {% trans "A Python server suitable for microservices based on Rest API." %}</p>
</div>
</div>
</div>
Expand Down

0 comments on commit 9fc1f0c

Please sign in to comment.