fixing rows
This commit is contained in:
parent
5e9b9bf08d
commit
17f8aebb94
|
@ -25,11 +25,15 @@ class Metrics:
|
|||
"""
|
||||
return {'type': '',
|
||||
'action_type': 'Status',
|
||||
'document_name': '',
|
||||
'status_receiver': self.status_receiver,
|
||||
'status_supplier': self.status_supplier,
|
||||
'status_receiver_created': '',
|
||||
'status_supplier_created': '',
|
||||
'trade_supplier': '',
|
||||
'trade_receiver': self.act.author,
|
||||
'trade_receiver': self.act.author.email,
|
||||
'trade_confirmed': '',
|
||||
'trade_weight': 0,
|
||||
'action_create_by': self.action_create_by,
|
||||
'devicehubID': self.devicehub_id,
|
||||
'hid': self.hid,
|
||||
|
@ -54,6 +58,7 @@ class Metrics:
|
|||
self.last_trade['status_supplier_created'] = self.act.created
|
||||
return
|
||||
|
||||
self.action_create_by = 'Receiver'
|
||||
if self.last_trade:
|
||||
# if exist one trade action before
|
||||
self.last_trade['status_receiver'] = self.act.type
|
||||
|
@ -61,9 +66,8 @@ class Metrics:
|
|||
return
|
||||
|
||||
# If not exist any trade action for this device
|
||||
self.action_create_by = 'Receiver'
|
||||
row = self.get_template_row()
|
||||
row['type'] = 'Status'
|
||||
row['status_receiver_created'] = self.act.created
|
||||
self.rows.append(row)
|
||||
|
||||
def get_snapshot(self):
|
||||
|
@ -134,8 +138,8 @@ class Metrics:
|
|||
self.last_trade = row
|
||||
row['type'] = 'Trade'
|
||||
row['action_type'] = 'Trade'
|
||||
row['trade_supplier'] = self.act.user_from
|
||||
row['trade_receiver'] = self.act.user_to
|
||||
row['trade_supplier'] = self.act.user_from.email
|
||||
row['trade_receiver'] = self.act.user_to.email
|
||||
row['self.status_receiver'] = self.status_receiver
|
||||
row['self.status_supplier'] = self.status_supplier
|
||||
row['trade_confirmed'] = self.get_confirms()
|
||||
|
|
|
@ -427,9 +427,20 @@ class ActionRow(OrderedDict):
|
|||
# General information about allocates, deallocate and lives
|
||||
self['DHID'] = allocate['devicehubID']
|
||||
self['Hid'] = allocate['hid']
|
||||
self['Start'] = allocate['start']
|
||||
self['FinalUserCode'] = allocate['finalUserCode']
|
||||
self['NumEndUsers'] = allocate['numEndUsers']
|
||||
self['Document-Name'] = allocate['document_name']
|
||||
self['Action-Type'] = allocate['action_type']
|
||||
self['Action-User-LastOwner-Supplier'] = allocate['trade_supplier']
|
||||
self['Action-User-LastOwner-Receiver'] = allocate['trade_receiver']
|
||||
self['Action-Create-By'] = allocate['action_create_by']
|
||||
self['Trade-Confirmed'] = allocate['trade_confirmed']
|
||||
self['Status-Supplier'] = allocate['status_supplier']
|
||||
self['Status-Receiver'] = allocate['status_receiver']
|
||||
self['Status Supplier – Created Date'] = allocate['status_supplier_created']
|
||||
self['Status Receiver – Created Date'] = allocate['status_receiver_created']
|
||||
self['Trade-Weight'] = allocate['trade_weight']
|
||||
self['Allocate-Start'] = allocate['start']
|
||||
self['Allocate-User-Code'] = allocate['finalUserCode']
|
||||
self['Allocate-NumUsers'] = allocate['numEndUsers']
|
||||
self['UsageTimeAllocate'] = allocate['usageTimeAllocate']
|
||||
self['Type'] = allocate['type']
|
||||
self['LiveCreate'] = allocate['liveCreate']
|
||||
|
|
|
@ -136,7 +136,11 @@ def test_metrics_action_status(user: UserClient, user2: UserClient):
|
|||
item='actions/',
|
||||
accept='text/csv',
|
||||
query=[('filter', {'type': ['Computer']})])
|
||||
import pdb; pdb.set_trace()
|
||||
# import pdb; pdb.set_trace()
|
||||
head = 'DHID;Hid;Document-Name;Action-Type;Action-User-LastOwner-Supplier;Action-User-LastOwner-Receiver;Action-Create-By;Trade-Confirmed;Status-Supplier;Status-Receiver;Status Supplier – Created Date;Status Receiver – Created Date;Trade-Weight;Allocate-Start;Allocate-User-Code;Allocate-NumUsers;UsageTimeAllocate;Type;LiveCreate;UsageTimeHdd\n'
|
||||
body = '93652;desktop-lenovo-9644w8n-0169622-00:1a:6b:5e:7f:10;;Status;;foo@foo.com;Receiver;;;Use;;'
|
||||
assert head in csv_str
|
||||
assert body in csv_str
|
||||
|
||||
|
||||
@pytest.mark.mvp
|
||||
|
@ -156,6 +160,7 @@ def test_complet_metrics(user: UserClient, user2: UserClient):
|
|||
res=Lot,
|
||||
item='{}/devices'.format(lot['id']),
|
||||
query=devices)
|
||||
import pdb; pdb.set_trace()
|
||||
# request_post = {
|
||||
# 'type': 'Trade',
|
||||
# 'devices': [span1['device']['id'], snap2['device']['id']],
|
||||
|
|
Reference in New Issue