Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #215 from serfend/JxTrade
Browse files Browse the repository at this point in the history
fix[trade]cache data should follow type
  • Loading branch information
Serfend committed Jun 22, 2023
2 parents 703fa84 + 1691f5c commit f9bba69
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/plugins/jx3/price_goods/lib/GoodsBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __repr__(self) -> str:
@property
def priority(self) -> int:
v_bind = 1 if self.bind_type == GoodsBindType.BindOnPick else 0
v_create_id = self.ui_id
v_create_id = self.ui_id or 0
return 1e8 * self.u_popularity - v_bind * 1e12 + v_create_id

@property
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/jx3/price_goods/lib/GoodsInfoFullExt.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

def check_cache_integrity(current_cache: dict, new_data: dict):
# 当前缓存没有缓存品数,应为其缓存
cached_level = 'level' in current_cache
cached_level = not current_cache.get('level') is None
should_update_cache = not cached_level
if not should_update_cache:
return
current_cache['level'] = new_data.get('Level')
CACHE_Goods[current_cache['id']] = current_cache
CACHE_Goods[current_cache['id']] = dict2obj(GoodsInfo(), current_cache)
flush_CACHE_Goods()


Expand All @@ -22,7 +22,7 @@ async def from_id(id: str) -> GoodsInfoFull:
if not cache_data is None:
current_cache = cache_data.to_dict()
check_cache_integrity(current_cache, data)

x = copy.deepcopy(current_cache)
x.update(data)
data = x
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/jx3/price_goods/lib/GoodsSerializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def default(self, o) -> str:


def flush_CACHE_Goods_Common(cache_file: str, target_dict: dict):
d = dict([key, target_dict[key].__dict__] for key in target_dict)
d = dict([key, target_dict[key].__dict__ if not type(
target_dict[key]) == dict else target_dict[key]] for key in target_dict)
data = json.dumps(d, cls=GoodsSerializerEncoder)
write(cache_file, data)

0 comments on commit f9bba69

Please sign in to comment.