This commit is contained in:
dx-tan 2024-02-02 18:29:10 +07:00
commit 793205bb41
6 changed files with 43 additions and 12 deletions

View File

@ -394,7 +394,7 @@ class AccuracyViewSet(viewsets.ViewSet):
paginator = Paginator(reports, page_size) paginator = Paginator(reports, page_size)
page = paginator.get_page(page_number) page = paginator.get_page(page_number).order_by('created_at')
data = [] data = []
for report in page: for report in page:

View File

@ -130,10 +130,38 @@ class MonthReportAccumulate:
self.accumulate(report) self.accumulate(report)
return True return True
def clear(self):
self.month = None
self.total = {
'subs': "+",
'extraction_date': "Subtotal ()",
'total_images': 0,
'images_quality': {
'successful': 0,
'successful_percent': 0,
'bad': 0,
'bad_percent': 0
},
'average_accuracy_rate': {
'imei': IterAvg(),
'purchase_date': IterAvg(),
'retailer_name': IterAvg()
},
'average_processing_time': {
'imei': IterAvg(),
'invoice': IterAvg()
},
'usage': {
'imei':0,
'invoice': 0
}
}
self.data = []
def __call__(self): def __call__(self):
self.total["images_quality"]["successful_percent"] += self.total["images_quality"]["successful"]/self.total["total_images"] if self.total["total_images"] else 0
self.total["images_quality"]["bad_percent"] += self.total["images_quality"]["bad"]/self.total["total_images"] if self.total["total_images"] else 0
total = copy.deepcopy(self.total) total = copy.deepcopy(self.total)
total["images_quality"]["successful_percent"] = total["images_quality"]["successful"]/total["total_images"] if total["total_images"] else 0
total["images_quality"]["bad_percent"] = total["images_quality"]["bad"]/total["total_images"] if total["total_images"] else 0
total["average_accuracy_rate"]["imei"] = total["average_accuracy_rate"]["imei"]() total["average_accuracy_rate"]["imei"] = total["average_accuracy_rate"]["imei"]()
total["average_accuracy_rate"]["purchase_date"] = total["average_accuracy_rate"]["purchase_date"]() total["average_accuracy_rate"]["purchase_date"] = total["average_accuracy_rate"]["purchase_date"]()
total["average_accuracy_rate"]["retailer_name"] = total["average_accuracy_rate"]["retailer_name"]() total["average_accuracy_rate"]["retailer_name"] = total["average_accuracy_rate"]["retailer_name"]()

View File

@ -2,7 +2,7 @@
"name": "sbt-ui", "name": "sbt-ui",
"version": "0.1.0", "version": "0.1.0",
"scripts": { "scripts": {
"start": "NODE_ENV=development vite --host", "start": "NODE_ENV=development npm run extract && npm run compile && vite --host",
"build": "NODE_ENV=production npm run extract && npm run compile && tsc && vite build", "build": "NODE_ENV=production npm run extract && npm run compile && tsc && vite build",
"serve": "vite preview", "serve": "vite preview",
"extract": "lingui extract --clean", "extract": "lingui extract --clean",

View File

@ -96,8 +96,10 @@ export async function downloadReport(report_id: string) {
let filename = "report.xlsx"; let filename = "report.xlsx";
try { try {
let basename = response.headers['content-disposition'].split('filename=')[1].split('.')[0]; let basename = response.headers['content-disposition'].split('filename=')[1].split('.')[0];
let extension = response.headers['content-disposition'].split('.')[1].split(';')[0]; if (basename.charAt(0) === '_') {
filename = `${basename}.${extension}` basename = basename.substring(1);
}
filename = `${basename}.xlsx`
} catch(err) { } catch(err) {
console.log(err); console.log(err);
} }

View File

@ -84,12 +84,12 @@ services:
depends_on: depends_on:
db-sbt: db-sbt:
condition: service_started condition: service_started
command: sh -c "chmod -R 777 /app; sleep 5; python manage.py collectstatic --no-input && # command: sh -c "chmod -R 777 /app; sleep 5; python manage.py collectstatic --no-input &&
python manage.py makemigrations && # python manage.py makemigrations &&
python manage.py migrate && # python manage.py migrate &&
python manage.py compilemessages && # python manage.py compilemessages &&
gunicorn fwd.asgi:application -k uvicorn.workers.UvicornWorker --timeout 300 -b 0.0.0.0:9000" # pre-makemigrations on prod # gunicorn fwd.asgi:application -k uvicorn.workers.UvicornWorker --timeout 300 -b 0.0.0.0:9000" # pre-makemigrations on prod
# command: bash -c "tail -f > /dev/null" command: bash -c "tail -f > /dev/null"
minio: minio:
image: minio/minio image: minio/minio

@ -0,0 +1 @@
Subproject commit 220954c5c6bfed15e93e26b2adacf28ff8b75baf