Ejemplo n.º 1
0
    def clean(self, db: Session, currentDate: datetime.date):
        LOGGER.info('Performing database cleanup...')

        for policy in self._policies:
            LOGGER.debug(f'Enforcing retention policy: {policy}')

            policyStart = currentDate - timedelta(days=policy.ageInDays)

            allSensors = Crud.get_sensors(db, skip=0, limit=1000000)
            for sensor in allSensors:
                self._cleanup_measurements_for_sensor(sensor, db, policy,
                                                      policyStart)

        LOGGER.debug('Performing database vacuum...')
        Crud.perform_vacuum(db)

        LOGGER.info('Database cleanup done')

        if self._forceBackupAfterCleanup:
            Crud.BACKUP_SERVICE.backup()
Ejemplo n.º 2
0
async def read_sensors(skip: int = 0,
                       limit: int = 100,
                       db: Session = Depends(get_database)):
    return Crud.get_sensors(db, skip=skip, limit=limit)