fix rebase

This commit is contained in:
Cayo Puigdefabregas 2025-02-19 11:48:44 +01:00
parent fbf9df1d48
commit 282fe3f0e6
2 changed files with 10 additions and 13 deletions

View file

@ -12,7 +12,7 @@ from django.contrib.auth import get_user_model
from utils.save_snapshots import move_json, save_in_disk
from evidence.parse import Build
from evidence.models import Annotation
from evidence.models import SystemProperty
from lot.models import Lot, LotTag, DeviceLot
@ -85,9 +85,8 @@ def create_custom_id(dhid, uuid, user):
if not uuid or not dhid:
return
tag = Annotation.objects.filter(
tag = SystemProperty.objects.filter(
uuid=uuid,
type=Annotation.Type.SYSTEM,
key='CUSTOM_ID',
owner=user.institution
).first()
@ -95,9 +94,8 @@ def create_custom_id(dhid, uuid, user):
if tag or not uuid or not dhid:
return
Annotation.objects.create(
SystemProperty.objects.create(
uuid=uuid,
type=Annotation.Type.SYSTEM,
key='CUSTOM_ID',
value=dhid,
owner=user.institution,
@ -137,7 +135,7 @@ def migrate_snapshots(row, user):
### migration lots ###
def migrate_lots(row, user):
tag = row.get("type", "Temporal")
name = row.get("name")
name = row.get("lot_name")
ltag = LotTag.objects.filter(name=tag, owner=user.institution).first()
if tag and not ltag:
ltag = LotTag.objects.create(
@ -146,7 +144,7 @@ def migrate_lots(row, user):
user=user
)
if Lot.objects.filter(name=tag, owner=user.institution).first():
if Lot.objects.filter(name=name, owner=user.institution).first():
return
Lot.objects.create(
@ -164,8 +162,7 @@ def add_device_in_lot(row, user):
if not lot_name or not dhid:
return
dev = Annotation.objects.filter(
type=Annotation.Type.SYSTEM,
dev = SystemProperty.objects.filter(
key='CUSTOM_ID',
value=dhid,
owner=user.institution,

View file

@ -3,7 +3,7 @@
-- save dhids and uuids of snapshots
copy(
select d.devicehub_id as dhid, sp.uuid from usody.action_with_one_device as one
select d.devicehub_id as dhid, sp.uuid as uuid from usody.action_with_one_device as one
join usody.action as ac on ac.id=one.id
join usody.device as d on d.id=one.device_id
join usody.snapshot as sp on sp.id=one.id
@ -16,7 +16,7 @@ with (format csv, header, delimiter ';', quote '"');
-- save lots and types
copy(
select distinct l.name, 'Incoming' from usody.transfer as t
select distinct l.name as lot_name, 'Incoming' as type from usody.transfer as t
join usody.lot as l on l.id=t.lot_id
join common.user as u on u.id=l.owner_id
where u.email=:'email' and
@ -26,7 +26,7 @@ where u.email=:'email' and
with (format csv, header, delimiter ';', quote '"');
copy(
select distinct l.name, 'Outgoing' from usody.transfer as t
select distinct l.name as lot_name, 'Outgoing' as type from usody.transfer as t
join usody.lot as l on l.id=t.lot_id
join common.user as u on u.id=l.owner_id
where u.email=:'email' and
@ -36,7 +36,7 @@ where u.email=:'email' and
with (format csv, header, delimiter ';', quote '"');
copy(
select distinct l.name, 'Temporary' from usody.lot as l
select distinct l.name as lot_name, 'Temporary' as type from usody.lot as l
left join usody.transfer as t on t.lot_id=l.id
join common.user as u on u.id=l.owner_id
where u.email=:'email' and