Closed jeffsf closed 2 years ago
Currently
async def upload_json_v2_profile(self, profile: Union[bytes,
bytearray,
str]):
pbf = ProfileByFrames().from_json(profile)
await self.upload_profile(pbf)
async with aiosqlite.connect(config.database.FILENAME) as db:
await db_insert.profile(pbf, db, time.time())
logger.info("Returned from db insert")
So this will need a switch to be called either as de1/profile
or as db/add_profile
or something like that. Could "ignore" upload if not connected, but that changes behavior and isn't really predictable.
db.insert.profile()
should have the persistence of "last-installed profile" factored out and associated with DE1().upload_profile
.
Should return the ID and potentially the fingerprint to the caller for all options. Should log the ID as well (INFO)
Needs some bake time as a lot of internal logic was changed to permit the database save to happen without a DE1 connected. Looks like under 100 ms per profile, at least for reasonable ones (this one was 6 frames with 2 limiters)
2022-01-26 20:19:05,407 INFO [Controller] Database.Insert: Profile 5998acc556d75a353c45df36e408ae4ebfe521af added to profile table.
2022-01-26 20:19:05,417 INFO [InboundAPI] Inbound.HTTP: 69 200 "OK" - PUT /de1/profile/store HTTP/1.1 127.0.0.1
2022-01-26 20:19:05,420 DEBUG [InboundAPI] Inbound.HTTP: RTT: 69.0 ms PUT /de1/profile/store HTTP/1.1
PUT /pyde1/de1/profile/store [object ArrayBuffer] success:
[
{
"fingerprint": "d8e8c106bb21e2e2a587a0c92f9396249f79c8c3",
"id": "5998acc556d75a353c45df36e408ae4ebfe521af"
}
]
As suggested by @ebengoechea, allow the upload of profile to the database to proceed without a connected DE1
Will need to make sure that it doesn't impact "last known" profile on a later connection.