Skip to content

Commit c5460e5

Browse files
committed
suppresses pick year from artisan.plus beans selector and roast name suggestion if origin/name combination is unique
1 parent 2e071ee commit c5460e5

File tree

5 files changed

+41
-14
lines changed

5 files changed

+41
-14
lines changed

src/artisanlib/roast_properties.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -2228,10 +2228,14 @@ def coffeeSelectionChanged(self, n:int) -> None:
22282228
self.plus_coffee_selected = cd.get('hr_id','')
22292229
origin = ''
22302230
if 'origin' in cd and cd['origin'] is not None:
2231-
origin = cd['origin'] + ' '
2231+
origin = cd['origin']
22322232
picked = ''
2233-
if 'crop_date' in cd and 'picked' in cd['crop_date'] and len(cd['crop_date']['picked']) > 0 and cd['crop_date']['picked'][0] is not None:
2233+
if 'crop_date' in cd and 'picked' in cd['crop_date'] and len(cd['crop_date']['picked']) > 0 and cd['crop_date']['picked'][0] is not None and plus.stock.has_duplicate_origin_label(cd):
22342234
picked = f"{cd['crop_date']['picked'][0]}, "
2235+
if origin:
2236+
origin = f'{origin} '
2237+
elif origin:
2238+
picked = ', '
22352239
self.plus_coffee_selected_label = f"{origin}{picked}{cd.get('label','')}"
22362240
self.plus_blend_selected_label = None
22372241
self.plus_blend_selected_spec = None

src/includes/Machines/Santoker/Cube_Bluetooth_PID.aset

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ alarmcond=1, 1, 1, 1, 1, 1, 1
124124
alarmflag=1, 1, 1, 1, 1, 1, 1
125125
alarmguard=-1, -1, -1, -1, -1, 3, -1
126126
alarmnegguard=-1, -1, -1, -1, -1, -1, -1
127-
alarmoffset=1, 1, 1, 1, 1, 90, 1
127+
alarmoffset=2, 3, 1, 1, 1, 90, 1
128128
alarmsetlabel=
129129
alarmsfile=
130130
alarmsource=-3, -3, -3, -3, -3, -3, -3

src/plus/stock.py

+24-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
from artisanlib.util import (decodeLocal, encodeLocal, getDirectory, is_int_list, is_float_list, render_weight,
4040
weight_units, float2float, convertWeight)
4141
from plus import config, connection, controller, util
42-
from typing import Final, TypedDict, List, Union, Optional, Tuple, Dict, TextIO
42+
from typing import Final, TypedDict, List, Union, Optional, Tuple, Dict, TextIO, Set
4343
from typing_extensions import NotRequired # Python <=3.10
4444

4545

@@ -138,6 +138,7 @@ class Stock(TypedDict, total=False):
138138
BlendList = List[Union[str, List[List[Union[str,float]]]]]
139139

140140
stock:Optional[Stock] = None # holds the dict with the current stock data (coffees, blends,..)
141+
duplicate_coffee_origin_labels:Set[str] = set() # set of coffee origin+labels which need to be discrimiated by picked year if available
141142

142143
# in kg; only stock larger than stock_epsilon (10g)
143144
# will be considered, the rest ignored
@@ -149,6 +150,24 @@ class Stock(TypedDict, total=False):
149150
# updates the stock cache
150151

151152

153+
# re-calculate duplicate coffee origin labels
154+
def update_duplicate_coffee_origin_labels() -> None:
155+
global duplicate_coffee_origin_labels # pylint: disable=global-statement
156+
duplicate_coffee_origin_labels = set()
157+
if stock is not None and 'coffees' in stock:
158+
seen = set()
159+
for c in stock['coffees']:
160+
origin_label = f"{c.get('origin', '')}{c.get('label', '')}"
161+
if origin_label in seen:
162+
duplicate_coffee_origin_labels.add(origin_label)
163+
else:
164+
seen.add(origin_label)
165+
166+
def has_duplicate_origin_label(c:Coffee) -> bool:
167+
origin_label = f"{c.get('origin', '')}{c.get('label', '')}"
168+
return origin_label in duplicate_coffee_origin_labels
169+
170+
152171
####### Stock Update Thread
153172

154173
worker:Optional['Worker'] = None
@@ -207,6 +226,7 @@ def fetch(self) -> bool:
207226
stock = j['result']
208227
if stock is not None:
209228
stock['retrieved'] = time.time()
229+
update_duplicate_coffee_origin_labels()
210230
_log.debug('-> retrieved')
211231
# _log.debug("stock = %s", stock)
212232
finally:
@@ -285,6 +305,7 @@ def load() -> None:
285305
f:TextIO
286306
with open(stock_cache_path, encoding='utf-8') as f:
287307
stock = json.load(f)
308+
update_duplicate_coffee_origin_labels()
288309
except Exception as e: # pylint: disable=broad-except
289310
_log.info(e)
290311
finally:
@@ -584,7 +605,7 @@ def coffeeLabel(c:Coffee) -> str:
584605
pass
585606
if origin != '':
586607
try:
587-
if 'crop_date' in c:
608+
if 'crop_date' in c and has_duplicate_origin_label(c):
588609
cy = c['crop_date']
589610
if (
590611
'picked' in cy
@@ -653,7 +674,7 @@ def getCoffees(weight_unit_idx:int, store:Optional[str]=None) -> List[Tuple[str,
653674
pass
654675
if origin != '':
655676
try:
656-
if 'crop_date' in c:
677+
if 'crop_date' in c and has_duplicate_origin_label(c):
657678
cy = c['crop_date']
658679
if (
659680
'picked' in cy

src/requirements-dev.txt

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
types-openpyxl>=3.1.5.20250306
22
types-Pillow>=10.2.0.20240822
3-
types-protobuf>=5.29.1.20250208
3+
types-protobuf>=5.29.1.20250315
44
types-psutil>=7.0.0.20250218
55
types-pyserial>=3.5.0.20250304
66
types-python-dateutil==2.9.0.20241206
7-
types-pytz>=2025.1.0.20250204
7+
types-pytz>=2025.1.0.20250318
88
types-pyyaml>=6.0.12.20241230
99
types-requests>=2.32.0.20250306
1010
types-setuptools>=76.0.0.20250313
1111
types-urllib3>=1.26.25.14
1212
types-docutils>=0.21.0.20241128
1313
lxml-stubs>=0.5.1
1414
mypy==1.15.0
15-
pyright==1.1.396
16-
ruff>=0.11.0
17-
pylint==3.3.5
18-
pre-commit>=4.1.0
15+
pyright==1.1.397
16+
ruff>=0.11.2
17+
pylint==3.3.6
18+
pre-commit>=4.2.0
1919
pytest>=8.3.5
2020
pytest-cov==6.0.0
2121
#pytest-qt==4.4.0
@@ -25,8 +25,8 @@ pytest-cov==6.0.0
2525
#pytest-bdd==6.1.1
2626
#pytest-benchmark==4.0.0
2727
#pytest-mock==3.11.1
28-
hypothesis>=6.129.3
29-
coverage>=7.7.0
28+
hypothesis>=6.130.3
29+
coverage>=7.7.1
3030
coverage-badge==1.1.2
3131
codespell==2.4.1
3232
# the following 2 packages are not installed along aiohttp on Python3.12 and make mypy complain

wiki/ReleaseHistory.md

+2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ v3.1.1
5353
- improved accuracy on rendering [artisan.plus](https://artisan.plus) blend component weights
5454
- improved Cropster importer
5555
- event replay not at any time ensures that only future events are replayed. As the set of future events may change on moving the background profile, an event can be replayed again. In previous Artisan versions, events did replay only once.
56+
- persist Energy Tab summary choice
57+
- suppresses pick year from [artisan.plus](https://artisan.plus) beans pop up and roast name suggestion if origin/name combination is unique
5658

5759
* FIXES
5860
- ensure complete reset to defaults in energy tab loads tab

0 commit comments

Comments
 (0)