Skip to content

Commit

Permalink
partial add new sort
Browse files Browse the repository at this point in the history
fix  caching
  • Loading branch information
datawhores committed Oct 2, 2024
1 parent dc26d09 commit b195eef
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
12 changes: 4 additions & 8 deletions ofscraper/classes/table/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,11 +462,7 @@ async def _sort_helper(self, label=None,reverse=None):
reverse=self.reverse,
)
elif key == "downloaded":
self._sorted_rows = sorted(
self.table_data,
key=lambda x: 1 if x.get_compare_val(key) is True else 0,
reverse=self.reverse,
)
self.query_one(DataTable).sort("downloaded",key=lambda x:x.plain)

elif key == "unlocked":
self._sorted_rows = sorted(
Expand Down Expand Up @@ -546,8 +542,8 @@ async def _sort_helper(self, label=None,reverse=None):
key=lambda x: x.get_compare_val(key),
reverse=self.reverse,
)
self._set_sorted_hash(key, self._sorted_rows)
await asyncio.get_event_loop().run_in_executor(None, self.update_table)
# self._set_sorted_hash(key, self._sorted_rows)
# await asyncio.get_event_loop().run_in_executor(None, self.update_table)

def _get_sorted_hash(self, key):
return self._sorted_hash.get(f"{key}_{self.reverse}")
Expand Down Expand Up @@ -622,7 +618,7 @@ def make_table(self):
table.clear(True)
table.fixed_rows = 0
table.zebra_stripes = True
table.add_column("number")
table.add_column("number",key="number")
[
table.add_column(re.sub("_", " ", ele), key=str(ele))
for ele in row_names()
Expand Down
4 changes: 2 additions & 2 deletions ofscraper/data/api/common/cache/write.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ def set_after_checks(model_id, api):
def set_full_after_scan_check(model_id, api):
api = api.lower()
cache.set(
f"{model_id}_full_{api}_scrape", read_args.retriveArgs().after is not None
f"{model_id}_full_{api}_v2_scrape", read_args.retriveArgs().after is not None
)


def set_check_mode_posts(model_id, api, all_posts):
api = api.lower()
cache.set(
f"{api}_check_{model_id}",
f"{api}_v2_check_{model_id}",
list(all_posts),
expire=constants.getattr("THREE_DAY_SECONDS"),
)
2 changes: 1 addition & 1 deletion ofscraper/utils/args/parse/group_bundles/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ def common_args_check(func):
media_id_filter,
media_type_option,
check_mode_media_sort,
media_desc_option,
length_max,
length_min,
media_desc_option,
help="Filters for controlling the initial table view"
)
@file_options
Expand Down

0 comments on commit b195eef

Please sign in to comment.