2022-03-04 Fred Gleason <fredg@paravelsystems.com>

* Fixed a bug in rdimport(1) that could create duplicate
	Scheduler Code entries when using the '--to-cart' and
	'--add-scheduler-code' switches simultaneously.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason
2022-03-04 15:39:19 -05:00
parent bcb22cc706
commit e7320d5eb5
3 changed files with 24 additions and 7 deletions

View File

@@ -22930,3 +22930,7 @@
2022-03-02 Fred Gleason <fredg@paravelsystems.com>
* Implemented sorting of the group list in the 'Rivendell Group
List' dialog in rdadmin(1).
2022-03-04 Fred Gleason <fredg@paravelsystems.com>
* Fixed a bug in rdimport(1) that could create duplicate
Scheduler Code entries when using the '--to-cart' and
'--add-scheduler-code' switches simultaneously.

View File

@@ -2,7 +2,7 @@
//
// Abstract a Rivendell Cart.
//
// (C) Copyright 2002-2021 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2022 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@@ -308,23 +308,36 @@ QStringList RDCart::schedCodesList() const
}
void RDCart::setSchedCodesList(const QStringList &codes) const
void RDCart::setSchedCodesList(QStringList codes) const
{
RDSqlQuery *q;
QString sql;
RDSqlQuery *q;
QString sched_codes="";
sql=QString("delete from `CART_SCHED_CODES` where ")+
QString::asprintf("`CART_NUMBER`=%u",cart_number);
RDSqlQuery::apply(sql);
//
// Normalize Codes
//
sql=QString("select `CODE` from `SCHED_CODES`");
q=new RDSqlQuery(sql);
while(q->next()) {
for(int i=0;i<codes.size();i++) {
if(codes.at(i).toLower()==q->value(0).toString().toLower()) {
codes[i]=q->value(0).toString();
}
}
}
delete q;
codes.removeDuplicates();
for(int i=0;i<codes.size();i++) {
sql=QString("insert into `CART_SCHED_CODES` set ")+
QString::asprintf("`CART_NUMBER`=%u,",cart_number)+
"SCHED_CODE='"+RDEscapeString(codes.at(i))+"'";
q=new RDSqlQuery(sql);
delete q;
RDSqlQuery::apply(sql);
}
}

View File

@@ -2,7 +2,7 @@
//
// Abstract a Rivendell Cart
//
// (C) Copyright 2002-2020 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2022 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@@ -65,7 +65,7 @@ class RDCart
QString schedCodes() const;
void setSchedCodes(const QString &sched_codes) const;
QStringList schedCodesList() const;
void setSchedCodesList(const QStringList &codes) const;
void setSchedCodesList(QStringList codes) const;
void addSchedCode(const QString &code) const;
void removeSchedCode(const QString &code) const;
void updateSchedCodes(const QString &add_codes,