blueghostuk / trainnotifier-server

Downloads data https://datafeeds.networkrail.co.uk/
http://www.trainnotifier.co.uk/
GNU General Public License v2.0
6 stars 1 forks source link

get schedules regardless of whether theyre activated #70

Open blueghostuk opened 11 years ago

blueghostuk commented 11 years ago

the following query is a good start

SELECT  [ScheduleId],[TrainUid],[OriginStopTiplocId],[DestinationStopTiplocId]
FROM    (SELECT 
            [ScheduleTrain].[ScheduleId],
            [ScheduleTrain].[TrainUid],
            [ScheduleTrain].[OriginStopTiplocId],
            [ScheduleTrain].[DestinationStopTiplocId],
            ROW_NUMBER() OVER (PARTITION BY [ScheduleTrain].[TrainUid] ORDER BY [ScheduleTrain].[STPIndicatorId]) AS [RowNumber]
         FROM   [ScheduleTrain]
         WHERE  [RunsMonday] = 1
            AND '2013-04-15' >= [StartDate]
            AND '2013-04-15' <= [EndDate]) AS a
WHERE   a.RowNumber = 1

SQL Management Studio suggests the following index:

/*
Missing Index Details from ...
The Query Processor estimates that implementing the following index could improve the query cost by 54.7833%.
*/

/*
USE [natrail]
GO
CREATE NONCLUSTERED INDEX [<Name of Missing Index, sysname,>]
ON [dbo].[ScheduleTrain] ([RunsMonday],[StartDate],[EndDate])
INCLUDE ([ScheduleId],[TrainUid],[STPIndicatorId],[OriginStopTiplocId],[DestinationStopTiplocId])
GO
*/

You would need one for each of RunsMonday... RunsSunday

blueghostuk commented 11 years ago

Schedule urls have changed to:

/Schedule/uid/{trainUid}/{date} - was /Schedule/{trainUid}/{date} /Schedule/stanox/{stanox}/{date} - new

blueghostuk commented 11 years ago

need to get signalling_id to store as headcode in schedule train - http://nrodwiki.rockshore.net/index.php/Schedule_Records