perf: 修改 django 版本

pull/8638/head
ibuler 2 years ago committed by Jiangjie.Bai
parent 60e455bea2
commit 12036f8c96

@ -18,7 +18,7 @@ from common.utils.common import lazyproperty
from common.utils import get_logger
from common.utils.timezone import local_now_date_display, utc_now
from common.exceptions import JMSException
from .models import AbstractSessionCommand
from terminal.models import Command
logger = get_logger(__file__)
@ -181,7 +181,7 @@ class CommandStore(object):
item['_source'].update({'id': item['_id']})
source_data.append(item['_source'])
return AbstractSessionCommand.from_multi_dict(source_data)
return Command.from_multi_dict(source_data)
def count(self, **query):
body = self.get_query_body(**query)

@ -47,21 +47,6 @@ class AbstractSessionCommand(OrgModelMixin):
risk_mapper = dict(cls.RISK_LEVEL_CHOICES)
return risk_mapper.get(risk_level)
@classmethod
def from_dict(cls, d):
self = cls()
for k, v in d.items():
setattr(self, k, v)
return self
@classmethod
def from_multi_dict(cls, l):
commands = []
for d in l:
command = cls.from_dict(d)
commands.append(command)
return commands
def to_dict(self):
d = {}
for field in self._meta.fields:

@ -1,7 +1,5 @@
from __future__ import unicode_literals
import time
from django.db import models
from django.db.models.signals import post_save
from django.utils.translation import ugettext_lazy as _
@ -47,6 +45,21 @@ class Command(AbstractSessionCommand):
cls.objects.bulk_create(commands)
print(f'Create {len(commands)} commands of org ({org})')
@classmethod
def from_dict(cls, d):
self = cls()
for k, v in d.items():
setattr(self, k, v)
return self
@classmethod
def from_multi_dict(cls, l):
commands = []
for d in l:
command = cls.from_dict(d)
commands.append(command)
return commands
class Meta:
db_table = "terminal_command"
ordering = ('-timestamp',)

@ -62,7 +62,7 @@ jsonfield2==4.0.0.post0
geoip2==4.5.0
ipip-ipdb==1.6.1
# Django environment
Django==3.1.14
Django==3.2.14
django-bootstrap3==14.2.0
django-filter==2.4.0
django-formtools==2.2

@ -1,4 +1,5 @@
#!/bin/bash
yum -y install \
gcc-c++ sshpass mariadb-devel openldap-devel libxml2-devel \
xmlsec1-devel xmlsec1-openssl-devel libtool-ltdl-devel
xmlsec1-devel xmlsec1-openssl-devel libtool-ltdl-devel \
postgresql-devel

Loading…
Cancel
Save