diff --git a/index.html b/index.html
index feb9576..c725e3c 100644
--- a/index.html
+++ b/index.html
@@ -20,8 +20,8 @@
- Recipient
-
+ To
+
Progress
@@ -233,8 +233,8 @@ async function handlePrimaryButtonClick() {
$.all('.columns').forEach(e => e.dispatchEvent(new Event('change')));
break;
case 'READY':
- let locale = $('#locale').value;
- let options = { locale, subcategories, save, mapping: new Object(), start: 2, limit: null };
+ let [start, end] = [null, null];
+ let options = { locale: $('#locale').value, subcategories, save, mapping: new Object() };
for (let element of $.all("input[type='number'].params")) {
parameters[element.id] = element.disabled ? null : element.valueAsNumber;
@@ -257,11 +257,11 @@ async function handlePrimaryButtonClick() {
}
if (options.slice) {
- options.limit = Math.min(minor || major, $('#chunksize').valueAsNumber);
- options.start += $('#offset').valueAsNumber * $('#chunksize').valueAsNumber;
+ 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;
case 'RUNNING':
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})`;
$('#subjectLabel').innerText = subject ?? '';
- $('#recipientLabel').innerText = recipient ? `${recipient} <${email}>` : email ?? '';
+ $('#toLabel').innerText = recipient ? `${recipient} <${email}>` : email ?? '';
let uptime = await Rpc2.invoke('uptime').catch(() => 0);
$('#uptimeLabel').innerText = Temporal.Duration.from({ seconds: uptime }).round({ largestUnit: 'hours' }).toLocaleString('en', { style: 'digital' });
diff --git a/main.py b/main.py
index b3253f2..2b277e5 100644
--- a/main.py
+++ b/main.py
@@ -65,11 +65,13 @@ def main(driver: Chrome, logger = logging.getLogger('main')):
wb: Workbook = None
filename: str = None
column: ColumnMapping = None
- limit = 0
+ start, end, limit = 2, 0, 0
- def begin(opts: dict, args: dict):
- nonlocal status
+ def begin(opts: dict, args: dict, i, j):
+ nonlocal status, start, end
if status != Status.READY: raise ValueError(status)
+ if i: start += i
+ if j: end = j
options.update(opts)
status = Status.RUNNING
parameters.update(args)
@@ -91,7 +93,7 @@ def main(driver: Chrome, logger = logging.getLogger('main')):
result = dict()
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)
result[key] = result.get(key, 0) + 1
@@ -315,7 +317,7 @@ def main(driver: Chrome, logger = logging.getLogger('main')):
source = load_workbook(buffer)
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)
c2 = wb.active.cell(row, col)
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)
raise Skip()
- if options.get('slice') and (start := options.get('start')) and (end := options.get('limit')):
- if index < start or index >= start + end:
- logger.info("[%d/%d] Not planned; skipping '%s'", index-1, limit-1, email)
- raise Next()
+ if options.get('slice'):
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)
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():
logger.info("[%d/%d] Already visited; skipping '%s'", index-1, limit-1, email)