Navigation Menu

Skip to content

Commit

Permalink
2018-02-15 Fred Gleason <fredg@paravelsystems.com>
Browse files Browse the repository at this point in the history
	* Added a 'SERVICES.LOG_SHELFLIFE_ORIGIN' field to the database.
	* Incremented the database version to 275.
	* Added a drop-down control to the 'Set Logs to auto-delete' control
	to allow origin to be specified in the 'Edit Service' dialog in
	rdadmin(1).
  • Loading branch information
Fred Gleason committed Feb 15, 2018
1 parent 948ccf4 commit 8f1bd70
Show file tree
Hide file tree
Showing 23 changed files with 180 additions and 42 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
Expand Up @@ -16598,3 +16598,9 @@
Guide.
2018-02-14 Fred Gleason <fredg@paravelsystems.com>
* Fixed a typo in an error message for the 'CopyAudio' web API call.
2018-02-15 Fred Gleason <fredg@paravelsystems.com>
* Added a 'SERVICES.LOG_SHELFLIFE_ORIGIN' field to the database.
* Incremented the database version to 275.
* Added a drop-down control to the 'Set Logs to auto-delete' control
to allow origin to be specified in the 'Edit Service' dialog in
rdadmin(1).
1 change: 1 addition & 0 deletions docs/tables/services.txt
Expand Up @@ -16,6 +16,7 @@ TRACK_GROUP char(10) From GROUPS.NAME
AUTOSPOT_GROUP char(10) From GROUPS.NAME
AUTO_REFRESH enum('N','Y')
DEFAULT_LOG_SHELFLIFE int(11)
LOG_SHELFLIFE_ORIGIN int(11) 0=Air Date, 1=Log Creation
ELR_SHELFLIFE int(11)
TFC_PATH char(255)
TFC_PREIMPORT_CMD text
Expand Down
2 changes: 1 addition & 1 deletion lib/dbversion.h
Expand Up @@ -24,7 +24,7 @@
/*
* Current Database Version
*/
#define RD_VERSION_DATABASE 274
#define RD_VERSION_DATABASE 275


#endif // DBVERSION_H
25 changes: 20 additions & 5 deletions lib/rdlog.cpp
Expand Up @@ -487,22 +487,26 @@ QString RDLog::xml() const


bool RDLog::create(const QString &name,const QString &svc_name,
const QString &user_name,QString *err_msg,RDConfig *config)
const QDate &air_date,const QString &user_name,
QString *err_msg,RDConfig *config)
{
QString sql;
RDSqlQuery *q;
int shelflife=-1;
RDSvc::ShelflifeOrigin shelforigin;
QString desc_tmpl;

sql=QString("select ")+
"DEFAULT_LOG_SHELFLIFE,"+ // 00
"DESCRIPTION_TEMPLATE "+ // 01
"LOG_SHELFLIFE_ORIGIN,"+ // 01
"DESCRIPTION_TEMPLATE "+ // 02
"from SERVICES where "+
"NAME=\""+RDEscapeString(svc_name)+"\"";
q=new RDSqlQuery(sql);
if(q->first()) {
shelflife=q->value(0).toInt();
desc_tmpl=q->value(1).toString();
shelforigin=(RDSvc::ShelflifeOrigin)q->value(1).toInt();
desc_tmpl=q->value(2).toString();
}
else {
*err_msg=QObject::tr("No such service!");
Expand All @@ -519,8 +523,19 @@ bool RDLog::create(const QString &name,const QString &svc_name,
"LINK_DATETIME=now(),"+
"SERVICE=\""+RDEscapeString(svc_name)+"\"";
if(shelflife>=0) {
sql+=",PURGE_DATE=\""+
QDate::currentDate().addDays(shelflife).toString("yyyy-MM-dd")+"\"";
switch(shelforigin) {
case RDSvc::OriginCreationDate:
sql+=",PURGE_DATE=\""+
QDate::currentDate().addDays(shelflife).toString("yyyy-MM-dd")+"\"";
break;

case RDSvc::OriginAirDate:
if(air_date.isValid()) {
sql+=",PURGE_DATE=\""+
air_date.addDays(shelflife).toString("yyyy-MM-dd")+"\"";
}
break;
}
}
q=new RDSqlQuery(sql);
if(!q->isActive()) {
Expand Down
4 changes: 2 additions & 2 deletions lib/rdlog.h
Expand Up @@ -79,8 +79,8 @@ class RDLog
RDLogEvent *createLogEvent() const;
QString xml() const;
static bool create(const QString &name,const QString &svc_name,
const QString &user_name,QString *err_msg,
RDConfig *config);
const QDate &air_date,const QString &user_name,
QString *err_msg,RDConfig *config);
static bool exists(const QString &name);
static bool remove(const QString &name,RDStation *station,RDUser *user,
RDConfig *config);
Expand Down
15 changes: 14 additions & 1 deletion lib/rdsvc.cpp
Expand Up @@ -158,6 +158,19 @@ void RDSvc::setDefaultLogShelflife(int days) const
}


RDSvc::ShelflifeOrigin RDSvc::logShelflifeOrigin() const
{
return (RDSvc::ShelflifeOrigin)RDGetSqlValue("SERVICES","NAME",svc_name,
"LOG_SHELFLIFE_ORIGIN").toInt();
}


void RDSvc::setLogShelflifeOrigin(RDSvc::ShelflifeOrigin orig)
{
SetRow("LOG_SHELFLIFE_ORIGIN",(int)orig);
}


int RDSvc::elrShelflife() const
{
return RDGetSqlValue("SERVICES","NAME",svc_name,"ELR_SHELFLIFE").toInt();
Expand Down Expand Up @@ -737,7 +750,7 @@ bool RDSvc::generateLog(const QDate &date,const QString &logname,
RDLog::remove(logname,svc_station,user,svc_config);
delete log_lock;
}
RDLog::create(logname,svc_name,"RDLogManager",err_msg,svc_config);
RDLog::create(logname,svc_name,date,"RDLogManager",err_msg,svc_config);
log_lock=new RDLogLock(logname,user,svc_station,this);
if(!TryLock(log_lock,err_msg)) {
delete log_lock;
Expand Down
3 changes: 3 additions & 0 deletions lib/rdsvc.h
Expand Up @@ -40,6 +40,7 @@ class RDSvc : public QObject
enum ImportField {CartNumber=0,ExtData=3,ExtEventId=4,ExtAnncType=5,
Title=6,StartHours=7,StartMinutes=8,StartSeconds=9,
LengthHours=10,LengthMinutes=11,LengthSeconds=12};
enum ShelflifeOrigin {OriginAirDate=0,OriginCreationDate=1};
RDSvc(QString svcname,RDStation *station,RDConfig *config,QObject *parent=0);
QString name() const;
bool exists() const;
Expand All @@ -59,6 +60,8 @@ class RDSvc : public QObject
void setAutoRefresh(bool state);
int defaultLogShelflife() const;
void setDefaultLogShelflife(int days) const;
ShelflifeOrigin logShelflifeOrigin() const;
void setLogShelflifeOrigin(ShelflifeOrigin orig);
int elrShelflife() const;
void setElrShelflife(int days) const;
bool chainto() const;
Expand Down
9 changes: 9 additions & 0 deletions rdadmin/createdb.cpp
Expand Up @@ -628,6 +628,7 @@ bool CreateDb(QString name,QString pwd,RDConfig *config)
"AUTOSPOT_GROUP char(10),"+
"AUTO_REFRESH enum('N','Y') default 'N',"+
"DEFAULT_LOG_SHELFLIFE int default -1,"+
"LOG_SHELFLIFE_ORIGIN int default 0,"+
"ELR_SHELFLIFE int default -1,"+
"TFC_PATH char(255),"+
"TFC_PREIMPORT_CMD text,"+
Expand Down Expand Up @@ -8013,6 +8014,14 @@ int UpdateDb(int ver,RDConfig *config)
delete q;
}

if(ver<275) {
sql=QString("alter table SERVICES ")+
"add column LOG_SHELFLIFE_ORIGIN int default 0 "+
"after DEFAULT_LOG_SHELFLIFE";
q=new RDSqlQuery(sql,false);
delete q;
}


//
// Maintainer's Note:
Expand Down
24 changes: 18 additions & 6 deletions rdadmin/edit_svc.cpp
Expand Up @@ -202,9 +202,17 @@ EditSvc::EditSvc(QString svc,QWidget *parent)
svc_loglife_spin->setRange(0,365);
connect(svc_loglife_box,SIGNAL(toggled(bool)),
svc_loglife_spin,SLOT(setEnabled(bool)));
label=new QLabel(svc_loglife_box,tr("days after creation"),this);
label->setGeometry(685,95,200,19);
label->setAlignment(AlignLeft|ShowPrefix);
svc_loglifeorigin_label=new QLabel(svc_loglife_box,tr("days after"),this);
svc_loglifeorigin_label->setGeometry(685,95,100,19);
svc_loglifeorigin_label->setAlignment(AlignLeft|ShowPrefix);
connect(svc_loglife_box,SIGNAL(toggled(bool)),
svc_loglifeorigin_label,SLOT(setEnabled(bool)));
svc_loglifeorigin_box=new QComboBox(this);
svc_loglifeorigin_box->insertItem(tr("air date"));
svc_loglifeorigin_box->insertItem(tr("creation"));
svc_loglifeorigin_box->setGeometry(750,93,100,19);
connect(svc_loglife_box,SIGNAL(toggled(bool)),
svc_loglifeorigin_box,SLOT(setEnabled(bool)));

//
// Purge Expired ELR Data
Expand Down Expand Up @@ -232,8 +240,6 @@ EditSvc::EditSvc(QString svc,QWidget *parent)
button->setText(tr("Enable &Hosts"));
connect(button,SIGNAL(clicked()),this,SLOT(enableHostsData()));



//
// Traffic Import Section
//
Expand Down Expand Up @@ -516,9 +522,13 @@ EditSvc::EditSvc(QString svc,QWidget *parent)
if(svc_svc->defaultLogShelflife()>=0) {
svc_loglife_box->setChecked(true);
svc_loglife_spin->setValue(svc_svc->defaultLogShelflife());
}
svc_loglifeorigin_box->setCurrentItem(svc_svc->logShelflifeOrigin());
svc_loglifeorigin_label->setEnabled(true);
}
else {
svc_loglife_spin->setDisabled(true);
svc_loglifeorigin_label->setDisabled(true);
svc_loglifeorigin_box->setDisabled(true);
}
if(svc_svc->elrShelflife()>=0) {
svc_shelflife_box->setChecked(true);
Expand Down Expand Up @@ -686,6 +696,8 @@ void EditSvc::Save()
svc_svc->setAutoRefresh(svc_autorefresh_box->isChecked());
if(svc_loglife_box->isChecked()) {
svc_svc->setDefaultLogShelflife(svc_loglife_spin->value());
svc_svc->setLogShelflifeOrigin((RDSvc::ShelflifeOrigin)
svc_loglifeorigin_box->currentItem());
}
else {
svc_svc->setDefaultLogShelflife(-1);
Expand Down
5 changes: 4 additions & 1 deletion rdadmin/edit_svc.h
Expand Up @@ -2,7 +2,7 @@
//
// Edit a Rivendell Service
//
// (C) Copyright 2002-2010,2016 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2010,2016-2017 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
Expand All @@ -23,6 +23,7 @@

#include <qdialog.h>
#include <qsqldatabase.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qspinbox.h>
#include <qcheckbox.h>
Expand Down Expand Up @@ -83,6 +84,8 @@ class EditSvc : public QDialog
QCheckBox *svc_autorefresh_box;
QCheckBox *svc_loglife_box;
QSpinBox *svc_loglife_spin;
QLabel *svc_loglifeorigin_label;
QComboBox *svc_loglifeorigin_box;
QCheckBox *svc_shelflife_box;
QSpinBox *svc_shelflife_spin;
bool import_changed;
Expand Down
14 changes: 11 additions & 3 deletions rdadmin/rdadmin_cs.ts
Expand Up @@ -3986,15 +3986,23 @@ uloženo. Uložit nyní?</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>days after creation</source>
<source>Purge ELR Data</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Purge ELR Data</source>
<source>days after airing</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>days after airing</source>
<source>days after</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>air date</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>creation</source>
<translation type="unfinished"></translation>
</message>
</context>
Expand Down
14 changes: 11 additions & 3 deletions rdadmin/rdadmin_de.ts
Expand Up @@ -3935,15 +3935,23 @@ gespeichert werden. Jetzt speichern?</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>days after creation</source>
<source>Purge ELR Data</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Purge ELR Data</source>
<source>days after airing</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>days after airing</source>
<source>days after</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>air date</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>creation</source>
<translation type="unfinished"></translation>
</message>
</context>
Expand Down
14 changes: 11 additions & 3 deletions rdadmin/rdadmin_es.ts
Expand Up @@ -3931,15 +3931,23 @@ debe guardarse. ¿Hacerlo ahora?</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>days after creation</source>
<source>Purge ELR Data</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Purge ELR Data</source>
<source>days after airing</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>days after airing</source>
<source>days after</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>air date</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>creation</source>
<translation type="unfinished"></translation>
</message>
</context>
Expand Down
14 changes: 11 additions & 3 deletions rdadmin/rdadmin_fr.ts
Expand Up @@ -3500,15 +3500,23 @@ must be saved. Save now?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>days after creation</source>
<source>Purge ELR Data</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Purge ELR Data</source>
<source>days after airing</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>days after airing</source>
<source>days after</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>air date</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>creation</source>
<translation type="unfinished"></translation>
</message>
</context>
Expand Down
14 changes: 11 additions & 3 deletions rdadmin/rdadmin_nb.ts
Expand Up @@ -3905,15 +3905,23 @@ Lagre no?</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>days after creation</source>
<source>Purge ELR Data</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Purge ELR Data</source>
<source>days after airing</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>days after airing</source>
<source>days after</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>air date</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>creation</source>
<translation type="unfinished"></translation>
</message>
</context>
Expand Down

0 comments on commit 8f1bd70

Please sign in to comment.