Removed hard-coded decade

This commit is contained in:
Sumner Evans
2021-02-03 13:46:33 -07:00
parent be32d97896
commit 75061b321e
3 changed files with 13 additions and 3 deletions

View File

@@ -40,6 +40,7 @@ from .api_objects import (
SearchResult,
Song,
)
from ..util import this_decade
class SongCacheStatus(Enum):
@@ -114,7 +115,7 @@ class AlbumSearchQuery:
GENRE = 8
type: Type
year_range: Tuple[int, int] = (2010, 2020)
year_range: Tuple[int, int] = this_decade()
genre: Genre = _Genre("Rock")
_strhash: Optional[str] = None

View File

@@ -5,6 +5,7 @@ from typing import Any, Callable, Dict, Optional, Set, Tuple, Type
from ..adapters import AlbumSearchQuery
from ..adapters.api_objects import Genre, Song
from ..util import this_decade
class RepeatType(Enum):
@@ -89,7 +90,7 @@ class UIState:
current_album_search_query: AlbumSearchQuery = AlbumSearchQuery(
AlbumSearchQuery.Type.RANDOM,
genre=_DefaultGenre(),
year_range=(2010, 2020),
year_range=this_decade(),
)
active_playlist_id: Optional[str] = None

View File

@@ -1,5 +1,6 @@
from datetime import datetime
from pathlib import Path
from typing import Union
from typing import Tuple, Union
def resolve_path(*joinpath_args: Union[str, Path]) -> Path:
@@ -12,3 +13,10 @@ def resolve_path(*joinpath_args: Union[str, Path]) -> Path:
f"{Path(*joinpath_args)} could not be found in any of the following "
"directories: {', '.join(roots)}"
)
def this_decade() -> Tuple[int, int]:
"""Returns a tuple representing the start and end year of the current decade."""
now = datetime.now()
decade_start = now.year // 10 * 10
return (decade_start, decade_start + 10)