Skip to content

Commit

Permalink
Merge pull request #7340 from kozlovsky/fix/ui_rename_updated_to_created
Browse files Browse the repository at this point in the history
Rename the column with a torrent's creation date from "Updated" to "Created" to avoid confusion
  • Loading branch information
kozlovsky committed Mar 29, 2023
2 parents c64313d + 3cc5800 commit 037d839
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def to_simple_dict(self):
"num_seeders": self.health.seeders,
"num_leechers": self.health.leechers,
"last_tracker_check": self.health.last_check,
"updated": int((self.torrent_date - epoch).total_seconds()),
"created": int((self.torrent_date - epoch).total_seconds()),
"tag_processor_version": self.tag_processor_version,
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
'size': "size",
'infohash': "infohash",
'date': "torrent_date",
'updated': "torrent_date",
'created': "torrent_date",
'status': 'status',
'torrents': 'num_entries',
'votes': 'votes',
Expand Down
4 changes: 2 additions & 2 deletions src/tribler/core/tests/test_search_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,10 @@ def test_title_rank():


def test_item_rank():
item = dict(name="abc", num_seeders=10, num_leechers=20, updated=time.time() - 10 * DAY)
item = dict(name="abc", num_seeders=10, num_leechers=20, created=time.time() - 10 * DAY)
assert item_rank("abc", item) == pytest.approx(0.88794642) # Torrent created ten days ago

item = dict(name="abc", num_seeders=10, num_leechers=20, updated=0)
item = dict(name="abc", num_seeders=10, num_leechers=20, created=0)
assert item_rank("abc", item) == pytest.approx(0.81964285) # Torrent creation date is unknown

item = dict(name="abc", num_seeders=10, num_leechers=20)
Expand Down
6 changes: 3 additions & 3 deletions src/tribler/core/utilities/search_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ def item_rank(query: str, item: dict) -> float:
:param query: a user-defined query string
:param item: a dict with torrent info.
Should include key `name`, can include `num_seeders`, `num_leechers`, `updated`
Should include key `name`, can include `num_seeders`, `num_leechers`, `created`
:return: the torrent rank value in range [0, 1]
"""

title = item['name']
seeders = item.get('num_seeders', 0)
leechers = item.get('num_leechers', 0)
updated = item.get('updated', 0)
freshness = None if updated <= 0 else time.time() - updated
created = item.get('created', 0)
freshness = None if created <= 0 else time.time() - created
return torrent_rank(query, title, seeders, leechers, freshness)


Expand Down
Binary file modified src/tribler/gui/i18n/es_ES.qm
Binary file not shown.
5 changes: 5 additions & 0 deletions src/tribler/gui/i18n/es_ES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,11 @@ Tenga en cuenta que los valores decimales están truncados.</translation>
<source>Health</source>
<translation>Enlaces</translation>
</message>
<message>
<location filename="../widgets/tablecontentmodel.py" line="57"/>
<source>Created</source>
<translation>Creado</translation>
</message>
<message>
<location filename="../widgets/tablecontentmodel.py" line="57"/>
<source>Updated</source>
Expand Down
Binary file modified src/tribler/gui/i18n/pt_BR.qm
Binary file not shown.
5 changes: 5 additions & 0 deletions src/tribler/gui/i18n/pt_BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
<source>Torrents</source>
<translation>Torrents</translation>
</message>
<message>
<location filename="../widgets/tablecontentmodel.py" line="56"/>
<source>Created</source>
<translation>Criado</translation>
</message>
<message>
<location filename="../widgets/tablecontentmodel.py" line="56"/>
<source>Updated</source>
Expand Down
Binary file modified src/tribler/gui/i18n/ru_RU.qm
Binary file not shown.
5 changes: 5 additions & 0 deletions src/tribler/gui/i18n/ru_RU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
<location filename="../widgets/tablecontentmodel.py" line="63"/>
<source>Health</source>
<translation>Состояние</translation>
</message>
<message>
<location filename="../widgets/tablecontentmodel.py" line="64"/>
<source>Created</source>
<translation>Создан</translation>
</message>
<message>
<location filename="../widgets/tablecontentmodel.py" line="64"/>
Expand Down
Binary file modified src/tribler/gui/i18n/zh_CN.qm
Binary file not shown.
5 changes: 5 additions & 0 deletions src/tribler/gui/i18n/zh_CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
<source>Health</source>
<translation>健康度</translation>
</message>
<message>
<location filename="../widgets/tablecontentmodel.py" line="56"/>
<source>Created</source>
<translation>创建时间</translation>
</message>
<message>
<location filename="../widgets/tablecontentmodel.py" line="56"/>
<source>Updated</source>
Expand Down
14 changes: 7 additions & 7 deletions src/tribler/gui/widgets/tablecontentmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Column(Enum):
NAME = auto()
SIZE = auto()
HEALTH = auto()
UPDATED = auto()
CREATED = auto()
VOTES = auto()
STATUS = auto()
STATE = auto()
Expand Down Expand Up @@ -62,7 +62,7 @@ def define_columns():
display_filter=lambda data: (format_size(float(data)) if data != "" else "")),
Column.HEALTH: d('health', tr("Health"), width=120, tooltip_filter=lambda data: f"{data}" + (
'' if data == HEALTH_CHECKING else '\n(Click to recheck)'), ),
Column.UPDATED: d('updated', tr("Updated"), width=120, display_filter=lambda timestamp: pretty_date(
Column.CREATED: d('created', tr("Created"), width=120, display_filter=lambda timestamp: pretty_date(
timestamp) if timestamp and timestamp > BITTORRENT_BIRTHDAY else "", ),
Column.VOTES: d('votes', tr("Popularity"), width=120, display_filter=format_votes,
tooltip_filter=lambda data: get_votes_rating_description(data) if data is not None else None, ),
Expand Down Expand Up @@ -407,7 +407,7 @@ def on_query_results(self, response, remote=False, on_top=False):


class ChannelContentModel(RemoteTableModel):
columns_shown = (Column.ACTIONS, Column.CATEGORY, Column.NAME, Column.SIZE, Column.HEALTH, Column.UPDATED)
columns_shown = (Column.ACTIONS, Column.CATEGORY, Column.NAME, Column.SIZE, Column.HEALTH, Column.CREATED)

def __init__(
self,
Expand Down Expand Up @@ -705,15 +705,15 @@ def show_remote_results(self):


class PopularTorrentsModel(ChannelContentModel):
columns_shown = (Column.CATEGORY, Column.NAME, Column.SIZE, Column.UPDATED)
columns_shown = (Column.CATEGORY, Column.NAME, Column.SIZE, Column.CREATED)

def __init__(self, *args, **kwargs):
kwargs["endpoint_url"] = 'channels/popular_torrents'
super().__init__(*args, **kwargs)


class DiscoveredChannelsModel(ChannelContentModel):
columns_shown = (Column.SUBSCRIBED, Column.NAME, Column.STATE, Column.TORRENTS, Column.VOTES, Column.UPDATED)
columns_shown = (Column.SUBSCRIBED, Column.NAME, Column.STATE, Column.TORRENTS, Column.VOTES, Column.CREATED)

@property
def default_sort_column(self):
Expand All @@ -732,7 +732,7 @@ class PersonalChannelsModel(ChannelContentModel):
Column.NAME,
Column.SIZE,
Column.HEALTH,
Column.UPDATED,
Column.CREATED,
Column.STATUS,
)

Expand Down Expand Up @@ -791,7 +791,7 @@ def edit_enabled(self):


class SimplifiedPersonalChannelsModel(PersonalChannelsModel):
columns_shown = (Column.ACTIONS, Column.CATEGORY, Column.NAME, Column.SIZE, Column.HEALTH, Column.UPDATED)
columns_shown = (Column.ACTIONS, Column.CATEGORY, Column.NAME, Column.SIZE, Column.HEALTH, Column.CREATED)

def __init__(self, *args, **kwargs):
kwargs["exclude_deleted"] = kwargs.get("exclude_deleted", True)
Expand Down

0 comments on commit 037d839

Please sign in to comment.