Add cache; bugfixing
This commit is contained in:
parent
74860be347
commit
d2160b9db5
|
@ -107,6 +107,7 @@ class DeviceView(View):
|
||||||
return self.schema.jsonify(device)
|
return self.schema.jsonify(device)
|
||||||
|
|
||||||
@auth.Auth.requires_auth
|
@auth.Auth.requires_auth
|
||||||
|
@cache(datetime.timedelta(minutes=1))
|
||||||
def find(self, args: dict):
|
def find(self, args: dict):
|
||||||
"""Gets many devices."""
|
"""Gets many devices."""
|
||||||
# Compute query
|
# Compute query
|
||||||
|
|
|
@ -20,9 +20,11 @@
|
||||||
<td>
|
<td>
|
||||||
{{ erasure.parent.serial_number.upper() }}
|
{{ erasure.parent.serial_number.upper() }}
|
||||||
</td>
|
</td>
|
||||||
|
{% else %}
|
||||||
|
<td></td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<td>
|
<td>
|
||||||
{{ erasure.parent.tags }}
|
{{ erasure.parent.tags.__format__('') }}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{{ erasure.device.serial_number.upper() }}
|
{{ erasure.device.serial_number.upper() }}
|
||||||
|
@ -55,6 +57,7 @@
|
||||||
<dd>{{ erasure.parent.tags }}</dd>
|
<dd>{{ erasure.parent.tags }}</dd>
|
||||||
<dt>Erasure:</dt>
|
<dt>Erasure:</dt>
|
||||||
<dd>{{ erasure.__format__('ts') }}</dd>
|
<dd>{{ erasure.__format__('ts') }}</dd>
|
||||||
|
{% if erasure.steps %}
|
||||||
<dt>Erasure steps:</dt>
|
<dt>Erasure steps:</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<ol>
|
<ol>
|
||||||
|
@ -63,6 +66,7 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ol>
|
</ol>
|
||||||
</dd>
|
</dd>
|
||||||
|
{% endif %}
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
@ -350,7 +350,10 @@ class EraseBasic(JoinedWithOneDeviceMixin, EventWithOneDevice):
|
||||||
else:
|
else:
|
||||||
std = 'no standard'
|
std = 'no standard'
|
||||||
v += 'Method used: {}, {}. '.format(self.method, std)
|
v += 'Method used: {}, {}. '.format(self.method, std)
|
||||||
v += '{} elapsed, on {}'.format(self.elapsed, self.date_str)
|
if self.end_time and self.start_time:
|
||||||
|
v += '{} elapsed. '.format(self.elapsed)
|
||||||
|
|
||||||
|
v += 'On {}'.format(self.date_str)
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,18 @@ class Event(Thing):
|
||||||
def url(self) -> urlutils.URL:
|
def url(self) -> urlutils.URL:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@property
|
||||||
|
def elapsed(self) -> timedelta:
|
||||||
|
pass
|
||||||
|
|
||||||
|
@property
|
||||||
|
def certificate(self) -> Optional[urlutils.URL]:
|
||||||
|
return None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def date_str(self):
|
||||||
|
return '{:%c}'.format(self.end_time or self.created)
|
||||||
|
|
||||||
|
|
||||||
class EventWithOneDevice(Event):
|
class EventWithOneDevice(Event):
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
|
import datetime
|
||||||
import uuid
|
import uuid
|
||||||
from collections import deque
|
from collections import deque
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Dict, List, Set, Union
|
from typing import Dict, List, Set, Union
|
||||||
|
|
||||||
import marshmallow as ma
|
import marshmallow as ma
|
||||||
|
import teal.cache
|
||||||
from flask import Response, jsonify, request
|
from flask import Response, jsonify, request
|
||||||
from marshmallow import Schema as MarshmallowSchema, fields as f
|
from marshmallow import Schema as MarshmallowSchema, fields as f
|
||||||
from teal.marshmallow import EnumField
|
from teal.marshmallow import EnumField
|
||||||
|
@ -50,6 +52,7 @@ class LotView(View):
|
||||||
lot = Lot.query.filter_by(id=id).one() # type: Lot
|
lot = Lot.query.filter_by(id=id).one() # type: Lot
|
||||||
return self.schema.jsonify(lot)
|
return self.schema.jsonify(lot)
|
||||||
|
|
||||||
|
@teal.cache.cache(datetime.timedelta(minutes=5))
|
||||||
def find(self, args: dict):
|
def find(self, args: dict):
|
||||||
"""
|
"""
|
||||||
Gets lots.
|
Gets lots.
|
||||||
|
|
|
@ -2,10 +2,10 @@ from contextlib import suppress
|
||||||
from typing import Set
|
from typing import Set
|
||||||
|
|
||||||
from boltons import urlutils
|
from boltons import urlutils
|
||||||
from sqlalchemy import BigInteger, Column, ForeignKey, Unicode, UniqueConstraint
|
from sqlalchemy import BigInteger, Column, ForeignKey, UniqueConstraint
|
||||||
from sqlalchemy.dialects.postgresql import UUID
|
from sqlalchemy.dialects.postgresql import UUID
|
||||||
from sqlalchemy.orm import backref, relationship, validates
|
from sqlalchemy.orm import backref, relationship, validates
|
||||||
from teal.db import DB_CASCADE_SET_NULL, Query, URL, check_lower
|
from teal.db import DB_CASCADE_SET_NULL, Query, URL
|
||||||
from teal.marshmallow import ValidationError
|
from teal.marshmallow import ValidationError
|
||||||
from teal.resource import url_for_resource
|
from teal.resource import url_for_resource
|
||||||
|
|
||||||
|
@ -123,4 +123,4 @@ class Tag(Thing):
|
||||||
return '{0.id} org: {0.org.name} device: {0.device}'.format(self)
|
return '{0.id} org: {0.org.name} device: {0.device}'.format(self)
|
||||||
|
|
||||||
def __format__(self, format_spec: str) -> str:
|
def __format__(self, format_spec: str) -> str:
|
||||||
return '{0.org.name} {0.id}'
|
return '{0.org.name} {0.id}'.format(self)
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
import teal.cache
|
||||||
from flask import Response, current_app as app, g, redirect, request
|
from flask import Response, current_app as app, g, redirect, request
|
||||||
from flask_sqlalchemy import Pagination
|
from flask_sqlalchemy import Pagination
|
||||||
from teal.marshmallow import ValidationError
|
from teal.marshmallow import ValidationError
|
||||||
|
@ -19,6 +22,7 @@ class TagView(View):
|
||||||
res = self._post_one()
|
res = self._post_one()
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
@teal.cache.cache(datetime.timedelta(minutes=1))
|
||||||
def find(self, args: dict):
|
def find(self, args: dict):
|
||||||
tags = Tag.query.filter(Tag.is_printable_q()) \
|
tags = Tag.query.filter(Tag.is_printable_q()) \
|
||||||
.order_by(Tag.created.desc()) \
|
.order_by(Tag.created.desc()) \
|
||||||
|
|
Reference in New Issue