Permalink
Browse files

Services API: Fix aggregation of channel and program information in G…

…etProgramGuide()
  • Loading branch information...
1 parent a180bbc commit 7c8e274633cea2684171e8d2daafe61b2e9732f5 @stuartm stuartm committed Oct 19, 2013
Showing with 21 additions and 4 deletions.
  1. +21 −4 mythtv/programs/mythbackend/services/guide.cpp
@@ -90,13 +90,16 @@ DTC::ProgramGuide *Guide::GetProgramGuide( const QDateTime &rawStartTime ,
ProgramList schedList;
MSqlBindings bindings;
+ // lpad is to allow natural sorting of numbers
QString sSQL = "WHERE program.chanid >= :StartChanId "
"AND program.chanid <= :EndChanId "
"AND program.endtime >= :StartDate "
"AND program.starttime <= :EndDate "
- "GROUP BY program.starttime, channel.channum, "
- "channel.callsign, program.title "
- "ORDER BY program.chanid, program.starttime ";
+ "GROUP BY program.starttime, channel.chanid "
+ "ORDER BY lpad(channel.channum, 10, 0), "
+ " callsign, "
+ " lpad(program.chanid, 10, 0), "
+ " program.starttime ";
bindings[":StartChanId"] = nStartChanId;
bindings[":EndChanId" ] = nEndChanId;
@@ -123,22 +126,36 @@ DTC::ProgramGuide *Guide::GetProgramGuide( const QDateTime &rawStartTime ,
int nChanCount = 0;
uint nCurChanId = 0;
DTC::ChannelInfo *pChannel = NULL;
+ QString sCurCallsign;
+ uint nSkipChanId = 0;
for( uint n = 0; n < progList.size(); n++)
{
ProgramInfo *pInfo = progList[ n ];
+ if ( nSkipChanId == pInfo->GetChanID())
+ continue;
+
if ( nCurChanId != pInfo->GetChanID() )
{
nChanCount++;
nCurChanId = pInfo->GetChanID();
+ // Filter out channels with the same callsign, keeping just the
+ // first seen
+ if (sCurCallsign == pInfo->GetChannelSchedulingID())
+ {
+ nSkipChanId = pInfo->GetChanID();
+ continue;
+ }
+
pChannel = pGuide->AddNewChannel();
FillChannelInfo( pChannel, pInfo->GetChanID(), bDetails );
- }
+ sCurCallsign = pChannel->CallSign();
+ }
DTC::Program *pProgram = pChannel->AddNewProgram();

0 comments on commit 7c8e274

Please sign in to comment.