fix: task slicing range
This commit is contained in:
+8
-8
@@ -20,8 +20,8 @@
|
|||||||
<span class="less ellipsis pure-u-3-4" id="fromLabel"></span>
|
<span class="less ellipsis pure-u-3-4" id="fromLabel"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="inline-flex pure-u-1 pure-u-sm-1-2">
|
<div class="inline-flex pure-u-1 pure-u-sm-1-2">
|
||||||
<span class="ellipsis pure-u-1-4">Recipient</span>
|
<span class="ellipsis pure-u-1-4">To</span>
|
||||||
<span class="less ellipsis pure-u-3-4" id="recipientLabel"></span>
|
<span class="less ellipsis pure-u-3-4" id="toLabel"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="inline-flex pure-u-1 pure-u-sm-1-2">
|
<div class="inline-flex pure-u-1 pure-u-sm-1-2">
|
||||||
<span class="ellipsis pure-u-1-4">Progress</span>
|
<span class="ellipsis pure-u-1-4">Progress</span>
|
||||||
@@ -233,8 +233,8 @@ async function handlePrimaryButtonClick() {
|
|||||||
$.all('.columns').forEach(e => e.dispatchEvent(new Event('change')));
|
$.all('.columns').forEach(e => e.dispatchEvent(new Event('change')));
|
||||||
break;
|
break;
|
||||||
case 'READY':
|
case 'READY':
|
||||||
let locale = $('#locale').value;
|
let [start, end] = [null, null];
|
||||||
let options = { locale, subcategories, save, mapping: new Object(), start: 2, limit: null };
|
let options = { locale: $('#locale').value, subcategories, save, mapping: new Object() };
|
||||||
|
|
||||||
for (let element of $.all("input[type='number'].params")) {
|
for (let element of $.all("input[type='number'].params")) {
|
||||||
parameters[element.id] = element.disabled ? null : element.valueAsNumber;
|
parameters[element.id] = element.disabled ? null : element.valueAsNumber;
|
||||||
@@ -257,11 +257,11 @@ async function handlePrimaryButtonClick() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (options.slice) {
|
if (options.slice) {
|
||||||
options.limit = Math.min(minor || major, $('#chunksize').valueAsNumber);
|
start = $('#offset').valueAsNumber * $('#chunksize').valueAsNumber;
|
||||||
options.start += $('#offset').valueAsNumber * $('#chunksize').valueAsNumber;
|
end = Math.min(minor || major, $('#chunksize').valueAsNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
await Rpc2.invoke('begin', { params: [options, parameters] });
|
await Rpc2.invoke('begin', { params: [options, parameters, start, end] });
|
||||||
break;
|
break;
|
||||||
case 'RUNNING':
|
case 'RUNNING':
|
||||||
await Rpc2.invoke('pause');
|
await Rpc2.invoke('pause');
|
||||||
@@ -450,7 +450,7 @@ while (await new Promise(o => setTimeout(o, 1000, true))) {
|
|||||||
|
|
||||||
$('#progressLabel').innerText = `${parseFloat(count / total * 100).toFixed(2)}% (${count}/${total})`;
|
$('#progressLabel').innerText = `${parseFloat(count / total * 100).toFixed(2)}% (${count}/${total})`;
|
||||||
$('#subjectLabel').innerText = subject ?? '';
|
$('#subjectLabel').innerText = subject ?? '';
|
||||||
$('#recipientLabel').innerText = recipient ? `${recipient} <${email}>` : email ?? '';
|
$('#toLabel').innerText = recipient ? `${recipient} <${email}>` : email ?? '';
|
||||||
|
|
||||||
let uptime = await Rpc2.invoke('uptime').catch(() => 0);
|
let uptime = await Rpc2.invoke('uptime').catch(() => 0);
|
||||||
$('#uptimeLabel').innerText = Temporal.Duration.from({ seconds: uptime }).round({ largestUnit: 'hours' }).toLocaleString('en', { style: 'digital' });
|
$('#uptimeLabel').innerText = Temporal.Duration.from({ seconds: uptime }).round({ largestUnit: 'hours' }).toLocaleString('en', { style: 'digital' });
|
||||||
|
|||||||
@@ -65,11 +65,13 @@ def main(driver: Chrome, logger = logging.getLogger('main')):
|
|||||||
wb: Workbook = None
|
wb: Workbook = None
|
||||||
filename: str = None
|
filename: str = None
|
||||||
column: ColumnMapping = None
|
column: ColumnMapping = None
|
||||||
limit = 0
|
start, end, limit = 2, 0, 0
|
||||||
|
|
||||||
def begin(opts: dict, args: dict):
|
def begin(opts: dict, args: dict, i, j):
|
||||||
nonlocal status
|
nonlocal status, start, end
|
||||||
if status != Status.READY: raise ValueError(status)
|
if status != Status.READY: raise ValueError(status)
|
||||||
|
if i: start += i
|
||||||
|
if j: end = j
|
||||||
options.update(opts)
|
options.update(opts)
|
||||||
status = Status.RUNNING
|
status = Status.RUNNING
|
||||||
parameters.update(args)
|
parameters.update(args)
|
||||||
@@ -91,7 +93,7 @@ def main(driver: Chrome, logger = logging.getLogger('main')):
|
|||||||
result = dict()
|
result = dict()
|
||||||
col = headers.index(header) + 1
|
col = headers.index(header) + 1
|
||||||
|
|
||||||
for row in range(options.get('start'), limit + 1):
|
for row in range(start, limit + 1):
|
||||||
key = str(wb.active.cell(row, col).value)
|
key = str(wb.active.cell(row, col).value)
|
||||||
result[key] = result.get(key, 0) + 1
|
result[key] = result.get(key, 0) + 1
|
||||||
|
|
||||||
@@ -315,7 +317,7 @@ def main(driver: Chrome, logger = logging.getLogger('main')):
|
|||||||
source = load_workbook(buffer)
|
source = load_workbook(buffer)
|
||||||
source.active.cell(1, col).value = column.sent
|
source.active.cell(1, col).value = column.sent
|
||||||
|
|
||||||
for row in range(options.get('start'), limit + 1):
|
for row in range(start, limit + 1):
|
||||||
c1 = source.active.cell(row, col)
|
c1 = source.active.cell(row, col)
|
||||||
c2 = wb.active.cell(row, col)
|
c2 = wb.active.cell(row, col)
|
||||||
if not (c1.value and str(c1.value).strip()):
|
if not (c1.value and str(c1.value).strip()):
|
||||||
@@ -403,13 +405,13 @@ def main(driver: Chrome, logger = logging.getLogger('main')):
|
|||||||
logger.warning("[%d/%d] Exhausted all allowed attempts; skipping", index-1, limit-1)
|
logger.warning("[%d/%d] Exhausted all allowed attempts; skipping", index-1, limit-1)
|
||||||
raise Skip()
|
raise Skip()
|
||||||
|
|
||||||
if options.get('slice') and (start := options.get('start')) and (end := options.get('limit')):
|
if options.get('slice'):
|
||||||
if index < start or index >= start + end:
|
|
||||||
logger.info("[%d/%d] Not planned; skipping '%s'", index-1, limit-1, email)
|
|
||||||
raise Next()
|
|
||||||
if (items := options.get('subcategories')) and (item := str(cell(index, column.region).value)) not in items:
|
if (items := options.get('subcategories')) and (item := str(cell(index, column.region).value)) not in items:
|
||||||
logger.info("[%d/%d] Value '%s' not enlisted; skipping '%s'", index-1, limit-1, item, email)
|
logger.info("[%d/%d] Value '%s' not enlisted; skipping '%s'", index-1, limit-1, item, email)
|
||||||
raise Next()
|
raise Next()
|
||||||
|
if index < start or index >= start + end:
|
||||||
|
logger.info("[%d/%d] Not planned; skipping '%s'", index-1, limit-1, email)
|
||||||
|
raise Next()
|
||||||
|
|
||||||
if (sent := cell(index, column.sent).value) is not None and str(sent).strip():
|
if (sent := cell(index, column.sent).value) is not None and str(sent).strip():
|
||||||
logger.info("[%d/%d] Already visited; skipping '%s'", index-1, limit-1, email)
|
logger.info("[%d/%d] Already visited; skipping '%s'", index-1, limit-1, email)
|
||||||
|
|||||||
Reference in New Issue
Block a user