Skip to content

Commit

Permalink
Updating function names to match their functionality.
Browse files Browse the repository at this point in the history
  • Loading branch information
lrnselfreliance committed May 3, 2023
1 parent 8de805b commit e06f846
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion modules/archive/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ def search_archives(search_str: str, domain: str, limit: int, offset: int, order


@optional_session
def search_domains_by_directory(name: str, limit: int = 5, session: Session = None) -> List[Domain]:
def search_domains_by_name(name: str, limit: int = 5, session: Session = None) -> List[Domain]:
domains = session.query(Domain) \
.filter(Domain.domain.ilike(f'%{name}%')) \
.order_by(asc(Domain.domain)) \
Expand Down
2 changes: 1 addition & 1 deletion modules/videos/channel/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def download_channel(id_: int):


@optional_session
def search_channels_by_directory(name: str, limit: int = 5, session: Session = None) -> List[Channel]:
def search_channels_by_name(name: str, limit: int = 5, session: Session = None) -> List[Channel]:
channels = session.query(Channel) \
.filter(Channel.name.ilike(f'%{name}%')) \
.order_by(asc(Channel.name)) \
Expand Down
11 changes: 6 additions & 5 deletions wrolpi/files/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,18 @@ async def post_search_directories(_, body: schema.DirectoriesSearchRequest):
return response.empty()

from modules.videos.channel import lib as channels_lib
channel_directories = channels_lib.search_channels_by_directory(name=body.name)
channel_directories = [dict(path=i.directory, name=i.name) for i in channel_directories]
channels = channels_lib.search_channels_by_name(name=body.name)
channel_directories = [dict(path=i.directory, name=i.name) for i in channels]
channel_paths = [i['path'] for i in channel_directories]

from modules.archive import lib as archives_lib
domain_directories = archives_lib.search_domains_by_directory(name=body.name)
domain_directories = [dict(path=i.directory, domain=i.domain) for i in domain_directories]
domains = archives_lib.search_domains_by_name(name=body.name)
domain_directories = [dict(path=i.directory, domain=i.domain) for i in domains]
domain_paths = [i['path'] for i in domain_directories]

# Get all directories that match but do not contain the above directories.
from wrolpi.files.models import Directory
directories: List[Directory] = await lib.search_directories(
directories: List[Directory] = await lib.search_directories_by_name(
name=body.name,
excluded=list(map(str, channel_paths + domain_paths)))

Expand Down
2 changes: 1 addition & 1 deletion wrolpi/files/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ async def upsert_directories(parent_directories, directories):


@optional_session
async def search_directories(name: str, excluded: List[str] = None, limit: int = 20, session: Session = None) \
async def search_directories_by_name(name: str, excluded: List[str] = None, limit: int = 20, session: Session = None) \
-> List[Directory]:
"""Find the Directories whose names contain the `name` string."""
excluded = excluded or []
Expand Down

0 comments on commit e06f846

Please sign in to comment.