I want to do both ways.
Will the script overhead be very low? I am expecting the overhead to be low.
It will run once when the page opens.
I think you are right that reporting probably handles this nicely in a grouping.
I just don’t like always how the report looks, and it is not consistent with my other pages.
I think I have to make progress tomorrow morning, so I might do the report side first.
I am going to return to this tomorrow.
I think it will help me with my page, but it is costing me a bit of time.
The request was pretty specific so I think it will be worth it.
It will be a bit nice to figure out.
I think/hope @JordanCClark might appreciate this as a brain teaser.
This is sort of how far or close I got thus far:
### Sample Dataset to simulate query result
import random
headers = ['date', 'shift', 'line', 'hours', 'gross', 'net']
data = []
t_stamp = system.date.now()
for i in range(10):
if i<4:
date=t_stamp
else:
date = system.date.addHours(t_stamp, 8)
if i<4:
shift=1
else:
shift=2
lineCol=('b' +str(random.randrange(5)))
hoursCol=random.randrange(12)
gross= random.randrange(100)
net=random.randrange(100)
data.append([date,shift, lineCol,hoursCol,gross,net])
dataIn = system.dataset.toPyDataSet(system.dataset.toDataSet(headers, data))
#for row in dataIn:
# for value in row:
# print value
for row in dataIn:
print [row[colName] for colName in dataIn.getColumnNames()]
print '---'
dataOut=[]
#for row in range(dataIn.getRowCount()):
test=sum( dataIn.getValueAt(row,dataIn.getColumnIndex('net')) for row in range(dataIn.getRowCount()))
print test
def handleDivideZero(a,b):
return 0 if (a and b)==0 else a/b
print data
#data.append([t_stamp,0,' '+' testing this',0,0,test])
print data
#dataOut= system system.dataset.toPyDataSet(system.dataset.toDataSet(headers, data))
#index= dataIn[1][1]
test = (dataIn[row] for row in range(dataIn.getRowCount()) if dataIn[row][1]==2)
for thing in test:
for value in thing:
print value
I think if I can slice that last set, then I might be able to use .index
to find my inserts for shift 1 and shift 2.
I think I can use .append for shift 3.
Maybe I should just make a dataset of each shift one at a time, then append my totals after each one.
Then append all of datasets at the end.
Maybe I will do that tomorrow.