Skip to content

Commit

Permalink
Extend matching of recording, rule templates to include title.
Browse files Browse the repository at this point in the history
The order of precedence for matching is now title, category and
category_type.
  • Loading branch information
gigem committed Sep 5, 2022
1 parent 8feeff4 commit ecc24f1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
14 changes: 10 additions & 4 deletions mythtv/libs/libmythtv/recordingrule.cpp
Expand Up @@ -179,7 +179,8 @@ bool RecordingRule::LoadByProgram(const ProgramInfo* proginfo)
return false;
}
else
LoadTemplate(proginfo->GetCategory(), proginfo->GetCategoryTypeString());
LoadTemplate(proginfo->GetTitle(), proginfo->GetCategory(),
proginfo->GetCategoryTypeString());

if (m_type != kTemplateRecord &&
(m_searchType == kNoSearch || m_searchType == kManualSearch))
Expand Down Expand Up @@ -270,22 +271,27 @@ bool RecordingRule::LoadBySearch(RecSearchType lsearch, const QString& textname,
return true;
}

bool RecordingRule::LoadTemplate(const QString& category, const QString& categoryType)
bool RecordingRule::LoadTemplate(const QString& title,
const QString& category,
const QString& categoryType)
{
QString lcategory = category.isEmpty() ? "Default" : category;
QString lcategoryType = categoryType.isEmpty() ? "Default" : categoryType;

MSqlQuery query(MSqlQuery::InitCon());
query.prepare("SELECT recordid, category, "
" (category = :TITLE1) AS titlematch, "
" (category = :CAT1) AS catmatch, "
" (category = :CATTYPE1) AS typematch "
"FROM record "
"WHERE type = :TEMPLATE AND "
" (category = :CAT2 OR category = :CATTYPE2 "
" (category IN (:TITLE2, :CAT2, :CATTYPE2) "
" OR category = 'Default') "
"ORDER BY catmatch DESC, typematch DESC"
"ORDER BY titlematch DESC, catmatch DESC, typematch DESC"
);
query.bindValue(":TEMPLATE", kTemplateRecord);
query.bindValue(":TITLE1", title);
query.bindValue(":TITLE2", title);
query.bindValue(":CAT1", lcategory);
query.bindValue(":CAT2", lcategory);
query.bindValue(":CATTYPE1", lcategoryType);
Expand Down
4 changes: 3 additions & 1 deletion mythtv/libs/libmythtv/recordingrule.h
Expand Up @@ -40,7 +40,9 @@ class MTV_PUBLIC RecordingRule
bool LoadByProgram(const ProgramInfo* proginfo);
bool LoadBySearch(RecSearchType lsearch, const QString& textname, const QString& forwhat,
QString joininfo = "", ProgramInfo *pginfo = nullptr);
bool LoadTemplate(const QString& category, const QString& categoryType = "Default");
bool LoadTemplate(const QString& title,
const QString& category = "Default",
const QString& categoryType = "Default");

bool ModifyPowerSearchByID(int rid, const QString& textname, QString forwhat,
QString joininfo = "");
Expand Down

0 comments on commit ecc24f1

Please sign in to comment.