Calculating time-to-import for map pbf files in the backend. These times were created using a test RPi4. Encoding URL of archive files to prevent error which blocked displaying of archives.

This commit is contained in:
Roland 2022-03-12 09:50:16 -07:00
parent 6a22090e54
commit c815aa68c6
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
10 changed files with 46 additions and 59 deletions

View file

@ -1,8 +1,16 @@
from sqlalchemy import Column, Integer, Boolean, BigInteger
from wrolpi import dates
from wrolpi.common import Base, ModelHelper
from wrolpi.media_path import MediaPathType
RPI4_BYTES_PER_SECOND = 3963
def seconds_to_import(size: int) -> int:
"""Attempt to predict how long it will take an RPi4 to import a given PBF file."""
return max(int(size // RPI4_BYTES_PER_SECOND), 0)
class MapFile(Base, ModelHelper):
__tablename__ = 'map_file'
@ -18,4 +26,5 @@ class MapFile(Base, ModelHelper):
'path': self.path,
'imported': self.imported,
'size': self.size,
'time_to_import': dates.seconds_to_timestamp(seconds_to_import(self.size)),
}