2015-02-06 Fred Gleason <fredg@paravelsystems.com>

* Added a 'Spin Count' report in 'lib/export_spincount.cpp',
	'lib/rdreport.cpp' and 'lib/rdreport.h'.
This commit is contained in:
Fred Gleason 2015-02-06 18:05:44 -05:00
parent 93746cc761
commit aba02162d3
13 changed files with 168 additions and 1 deletions

View File

@ -14747,3 +14747,6 @@
* Incremented the package version to 2.10.2int04.
2015-02-06 Fred Gleason <fredg@paravelsystems.com>
* Fixed a typo in the rdmarkerset(8) man page.
2015-02-06 Fred Gleason <fredg@paravelsystems.com>
* Added a 'Spin Count' report in 'lib/export_spincount.cpp',
'lib/rdreport.cpp' and 'lib/rdreport.h'.

View File

@ -59,6 +59,7 @@ dist_librd_la_SOURCES = dbversion.h\
export_nprsoundex.cpp\
export_radiotraffic.cpp\
export_soundex.cpp\
export_spincount.cpp\
export_technical.cpp\
export_textlog.cpp\
html_gpl2.cpp\

122
lib/export_spincount.cpp Normal file
View File

@ -0,0 +1,122 @@
// export_spincount.cpp
//
// Export a Rivendell Spin Count Report to an ASCII Text File.
//
// (C) Copyright 2015 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
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include <stdio.h>
#include <map>
#include <qfile.h>
#include <qmessagebox.h>
#include <rddb.h>
#include <rdlog_line.h>
#include <rdairplay_conf.h>
#include <rdconf.h>
#include <rddatedecode.h>
#include <rdreport.h>
bool RDReport::ExportSpinCount(const QDate &startdate,const QDate &enddate,
const QString &mixtable)
{
QString sql;
RDSqlQuery *q;
FILE *f;
QString cut;
QString str;
QString cart_fmt;
QString cart_num;
std::map<unsigned,unsigned> carts;
std::map<unsigned,QString> titles;
std::map<unsigned,QString> artists;
std::map<unsigned,QString> labels;
std::map<unsigned,QString> albums;
#ifdef WIN32
QString filename=RDDateDecode(exportPath(RDReport::Windows),startdate);
#else
QString filename=RDDateDecode(exportPath(RDReport::Linux),startdate);
#endif
QFile file(filename);
if((f=fopen((const char *)filename,"w"))==NULL) {
report_error_code=RDReport::ErrorCantOpen;
return false;
}
if(useLeadingZeros()) {
cart_fmt=QString().sprintf("%%0%uu",cartDigits());
}
else {
cart_fmt="%6u";
}
//
// Generate Spin Counts
//
sql=QString("select CART_NUMBER,TITLE,ARTIST,ALBUM,LABEL ")+
"from `"+mixtable+"_SRT` order by TITLE";
q=new RDSqlQuery(sql);
while(q->next()) {
carts[q->value(0).toInt()]++;
titles[q->value(0).toInt()]=q->value(1).toString();
artists[q->value(0).toInt()]=q->value(2).toString();
albums[q->value(0).toInt()]=q->value(3).toString();
labels[q->value(0).toInt()]=q->value(4).toString();
}
delete q;
//
// Write File Header
//
if(startdate==enddate) {
fprintf(f," Rivendell Spin Count Report for %s\n",
(const char *)startdate.toString("MM/dd/yyyy"));
}
else {
fprintf(f," Rivendell Spin Count Report for %s - %s\n",
(const char *)startdate.toString("MM/dd/yyyy"),
(const char *)enddate.toString("MM/dd/yyyy"));
}
str=QString().sprintf("%s -- %s\n",(const char *)name(),
(const char *)description());
for(unsigned i=0;i<(132-str.length())/2;i++) {
fprintf(f," ");
}
fprintf(f,"%s\n",(const char *)str);
// fprintf(f,"------------------------------------------------------------------------------------------------------------------------------------\n");
fprintf(f,"--Title------------------------ --Artist----------------------- --Album------------------------ --Label----------------------- Spins\n");
//
// Write Data Rows
//
for(std::map<unsigned,unsigned>::const_iterator it=carts.begin();
it!=carts.end();it++) {
fprintf(f,"%-30s %-30s %-30s %-29s %5u\n",
(const char *)titles[it->first],
(const char *)artists[it->first],
(const char *)albums[it->first],
(const char *)labels[it->first],
it->second);
}
fclose(f);
report_error_code=RDReport::ErrorOk;
return true;
}

View File

@ -37,6 +37,7 @@ SOURCES += export_musicplayout.cpp
SOURCES += export_musicsummary.cpp
SOURCES += export_nprsoundex.cpp
SOURCES += export_radiotraffic.cpp
SOURCES += export_spincount.cpp
SOURCES += export_soundex.cpp
SOURCES += export_technical.cpp
SOURCES += export_textlog.cpp

View File

@ -423,6 +423,10 @@
<source>Mr. Master Reconciliation</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Spin Count</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAddCart</name>

View File

@ -419,6 +419,10 @@
<source>Mr. Master Reconciliation</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Spin Count</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAddCart</name>

View File

@ -419,6 +419,10 @@
<source>Mr. Master Reconciliation</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Spin Count</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAddCart</name>

View File

@ -405,6 +405,10 @@
<source>Mr. Master Reconciliation</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Spin Count</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAddCart</name>

View File

@ -419,6 +419,10 @@
<source>Mr. Master Reconciliation</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Spin Count</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAddCart</name>

View File

@ -419,6 +419,10 @@
<source>Mr. Master Reconciliation</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Spin Count</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAddCart</name>

View File

@ -419,6 +419,10 @@
<source>Mr. Master Reconciliation</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Spin Count</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RDAddCart</name>

View File

@ -642,6 +642,10 @@ bool RDReport::generateReport(const QDate &startdate,const QDate &enddate,
ret=ExportMusicPlayout(startdate,enddate,mixname);
break;
case RDReport::SpinCount:
ret=ExportSpinCount(startdate,enddate,mixname);
break;
case RDReport::MusicSummary:
ret=ExportMusicSummary(startdate,enddate,mixname);
break;
@ -718,6 +722,9 @@ QString RDReport::filterText(RDReport::ExportFilter filter)
case RDReport::NaturalLog:
return QObject::tr("NaturalLog Reconciliation");
case RDReport::SpinCount:
return QObject::tr("Spin Count");
case RDReport::WideOrbit:
return QObject::tr("WideOrbit Traffic Reconciliation");
@ -761,6 +768,7 @@ bool RDReport::multipleDaysAllowed(RDReport::ExportFilter filter)
case RDReport::MusicClassical:
case RDReport::MusicPlayout:
case RDReport::NaturalLog:
case RDReport::SpinCount:
case RDReport::WideOrbit:
return false;
@ -796,6 +804,7 @@ bool RDReport::multipleMonthsAllowed(RDReport::ExportFilter filter)
case RDReport::MusicSummary:
case RDReport::NprSoundExchange:
case RDReport::SoundExchange:
case RDReport::SpinCount:
case RDReport::Technical:
return true;
}

View File

@ -37,7 +37,8 @@ class RDReport
SoundExchange=4,RadioTraffic=5,VisualTraffic=6,
CounterPoint=7,Music1=8,MusicSummary=9,WideOrbit=10,
NprSoundExchange=11,MusicPlayout=12,NaturalLog=13,
MusicClassical=14,MrMaster=15,LastFilter=16};
MusicClassical=14,MrMaster=15,SpinCount=16,
LastFilter=17};
enum ExportOs {Linux=0,Windows=1};
enum ExportType {Generic=0,Traffic=1,Music=2};
enum StationType {TypeOther=0,TypeAm=1,TypeFm=2,TypeLast=3};
@ -114,6 +115,8 @@ class RDReport
const QString &mixtable);
bool ExportMusicSummary(const QDate &startdate,const QDate &enddate,
const QString &mixtable);
bool ExportSpinCount(const QDate &startdate,const QDate &enddate,
const QString &mixtable);
QString StringField(const QString &str,const QString &null_text="") const;
void SetRow(const QString &param,const QString &value) const;
void SetRow(const QString &param,int value) const;