Skip to content

Commit

Permalink
Prettify Is in Coll. column in dsc ls table
Browse files Browse the repository at this point in the history
  • Loading branch information
JOJ0 committed Nov 7, 2024
1 parent 84f6dc9 commit 097cfc6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion discodos/ctrl/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ def tui_ls_releases(self, search_terms):
"Cat. #",
"Artist",
"Title",
"D. Coll.",
"Is in C.",
"For Sale",
],
discogs=self.d
Expand Down
18 changes: 16 additions & 2 deletions discodos/model_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ def update_release_brainz(self, release_id, mbid, match_method):
tuple_upd = (mbid, match_method, release_id)
return self.execute_sql(sql_upd, tuple_upd)

# Newer fetchers and inserts
# Newer fetchers, inserts and helpers

def create_sales_entry(self, listing_object):
"""Creates a single entry to sales table and ensures up to date data.
Expand All @@ -909,6 +909,10 @@ def create_sales_entry(self, listing_object):
log.error("MODEL: create_sales_entry: %s", e.args[0])
return False

def bool_to_yes_no(self, value):
"""Convert 0/1 to 'No'/'Yes'."""
return "Yes" if value == 1 else "No"

def key_value_search_releases(
self, search_key_value=None, orderby="d_artist, discogs_title"
):
Expand All @@ -927,7 +931,7 @@ def key_value_search_releases(
)
join = [("LEFT", "sales", "discogs_id = d_sales_release_id")]

return self._select_simple(
rows = self._select_simple(
[
"discogs_id",
"d_catno",
Expand All @@ -939,3 +943,13 @@ def key_value_search_releases(
"release",
fetchone=False, orderby=orderby, condition=where, join=join
)
human_readable_rows = [
{
**row,
"in_d_collection": self.bool_to_yes_no(
row["in_d_collection"]
)
}
for row in rows
]
return human_readable_rows
4 changes: 2 additions & 2 deletions discodos/view/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ def action_edit_sale(self):
def _load_ls_results(self):
table_widget = self.query_one(DataTable)
for row in self.rows:
row_id, *_ = row
table_widget.add_row(*row, key=row_id)
row_id = row['discogs_id']
table_widget.add_row(*row.values(), key=row_id)

def on_mount(self):
self.title = "DiscoDOS ls results"
Expand Down

0 comments on commit 097cfc6

Please sign in to comment.