Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Scriptsmigrationfromold (#10)
Browse files Browse the repository at this point in the history
* Create placeholder

* Baseline Replacement of Learning Modules folder from folder in -OLD repo

* Complete prior commit

* First pass updates to scripts to accommodate changes to new WTP application

Updated Get-TenantKey to use MD5 and moved  to
CatalogAndDatabaseManagement
Renamed AppVersionSpecific to WtpConfig and updated all uses
Renamed Venues -> Venue in all SQL scripts
Updated uses of venue types in provisioning scripts to use new values
Changed email length validation for 50 chars
Removed all tutorials
Renamed EDJ user guide to remove 'private'

* First check in of new ticket generator

* Work in progress on new ticket generator

* Updates to fix issues with Auto Provision and add the 'curved' version of the ticket generator

* Update Demo-TicketGenerator script to enable use of the new 'curved' ticket generator

* Updates to fix bugs in auto provisioning

* Updates to fix provisioning bugs after migration

* Minor updates to demo- scripts, user config, and ticket generator and sales curves

* Refactor rename-database command to include sourcedatabasename and servername parameters

* Updates to catalog module for restore tenant scenarios

1. Added No echo to scripts to prevent printing out subscription info
twice
2. Replaced Remove-ExtendedTenantMetadataFromCatalog with
Remove-ExtendedTenant
3. The default databases deployed still do not come with sp_deleteEvent
installed

* Adding updates to TicketGenerator2 to be consistent with -OLD

* Removing AutoProvision from the release branch

* Revert "Removing AutoProvision from the release branch"

This reverts commit 1697ee5b95d22d420d9abf4aafc91d2f59dbdc47.

* Updated operational analytics scripts to point to latest ticket generator

* Also updated operational analytics scripts to use updated server name
prefix ('tenants1' not 'customers1')

* Updated database project to include sp_DeleteEvent

* Updated to remove launch of Admin app whch is not available in this release

* Removing reference to Databases table from Remove-ExtendedTenant

* refactoring to make removal of extended database data occur in catalog sync only

* Adding to previous commit

* Adding updates to replicated copies of  CatalogAndDatabaseManagement to AutoProvisioning folders

* Fixed bug that mismatched server used in case of golden server; fixed source of bacpac used in deploy tenant

* Add files via upload

* Update Demo-TenantAnalyticsDB.ps1

* Create foo.txt

* Add files via upload

* Updates to ticket generator to fix bugs and make consistent with OLD version

* Changing New-TenantBatch to use template from new release URL

* Add support for Go statements in Invoke-SqlAzure command

* Revert "Add support for Go statements in Invoke-SqlAzure command"

This reverts commit ef6f17cf875c2650d2e2fb57768b045e5598fa30.

* Addition of Search database info to WtpConfig

* Addition of search head database scenario based on EQ

* Corrections to venue types in SQL scripts in ref data update and in adhoc analytics db population

* Updating Search-related scripts

* Adding Server name to the data projected into the search database

* Feature jobs private preview warning (#9)

* Adding error message prompting users to download updated PowerShell SDK for elastic jobs APIs

* Add error checking to check if subscription is white-listed for Elastic jobs preview

* Adding TenantAnalyticsDW demo script files

* Fixing extra tab and LF that breaks script

* Updating behavior of InvokeSqlCmdOnTenantDatabases to include BaseTenantDB

* Removing specific script from Demo-InvokeSqlCmdOnTenantDatabases

* Fix latent bug in Get-Catalog

* Changed LoadGenerator to run continuously, looking for new dbs to add to the current load

* Tweaks to progress bar display behavior

* Removing New-Tenant file, function is in CatalogAndDatabaseManagement

* Suporting PostalCode input on single and batch tenants

* Increasing progress bar to show 10 minutes rows (60 * 10 seconds)

* Updated adhoc analytics queries to match those in -OLD

* Updated comments in Tenant Analytics scripts

* Changes to comments.  Removes unused variable assignment

* Update to readme with new linky thing.  removed references to features not supported in this release.

* Updated SQL files with TicketFacts and venue* 'global' views

* Removing search module

* updating postal codes used by ticket generator
  • Loading branch information
billgib authored and AyoOlubeko committed May 9, 2017
1 parent 300782f commit 86084c5
Show file tree
Hide file tree
Showing 39 changed files with 1,246 additions and 690 deletions.
27 changes: 14 additions & 13 deletions Learning Modules/Common/CatalogAndDatabaseManagement.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ function Get-Catalog

if (!$shardmapManager)
{
throw "Failed to initialize shard map manager from '$(config.CatalogDatabaseName)' database. Ensure catalog is initialized by opening the Events app and try again."
throw "Failed to initialize shard map manager from '$($config.CatalogDatabaseName)' database. Ensure catalog is initialized by opening the Events app and try again."
}

# Initialize shard map
Expand Down Expand Up @@ -994,7 +994,11 @@ function New-Tenant
[string]$PoolName,

[Parameter(Mandatory=$false)]
[string]$VenueType
[string]$VenueType,

[Parameter(Mandatory=$false)]
[string]$PostalCode = "98052"

)

$WtpUser = $WtpUser.ToLower()
Expand Down Expand Up @@ -1024,6 +1028,7 @@ function New-Tenant
-ElasticPoolName $PoolName `
-TenantName $TenantName `
-VenueType $VenueType `
-PostalCode $PostalCode `
-WtpUser $WtpUser

# Register the tenant and database in the catalog
Expand Down Expand Up @@ -1216,7 +1221,6 @@ function Remove-CatalogInfoFromTenantDatabase
-Password $adminPassword `
-ServerInstance ($TenantDatabase.ServerName + ".database.windows.net") `
-Database $TenantDatabase.DatabaseName `
-ConnectionTimeout 30 `
-Query $commandText `
}

Expand All @@ -1231,22 +1235,23 @@ function Remove-ExtendedDatabase
[parameter(Mandatory=$true)]
[object]$Catalog,

[parameter(Mandatory=$true)]
[string]$ServerName,

[parameter(Mandatory=$true)]
[string]$DatabaseName
)

$commandText = "
DELETE FROM Databases
WHERE DatabaseName = $DatabaseName;"
WHERE ServerName = '$ServerName' AND DatabaseName = '$DatabaseName';"

Invoke-SqlAzureWithRetry `
-ServerInstance $Catalog.FullyQualifiedServerName `
-Username $config.CatalogAdminuserName `
-Password $config.CatalogAdminPassword `
-Database $Catalog.Database.DatabaseName `
-Query $commandText `
-ConnectionTimeout 30 `
-QueryTimeout 30 `
}


Expand Down Expand Up @@ -1277,9 +1282,7 @@ function Remove-ExtendedElasticPool{
-Database $Catalog.Database.DatabaseName `
-Query $commandText `
-UserName $config.CatalogAdminUserName `
-Password $config.CatalogAdminPassword `
-ConnectionTimeout 30 `
-QueryTimeout 15
-Password $config.CatalogAdminPassword
}


Expand Down Expand Up @@ -1313,7 +1316,7 @@ function Remove-ExtendedServer

<#
.SYNOPSIS
Removes extended tenant and associated database meta data entries from catalog
Removes extended tenant entry from catalog
#>
function Remove-ExtendedTenant
{
Expand Down Expand Up @@ -1341,9 +1344,7 @@ function Remove-ExtendedTenant
# Delete the tenant name from the Tenants table
$commandText = "
DELETE FROM Tenants
WHERE TenantId = $rawkeyHexString;
DELETE FROM Databases
WHERE ServerName = '$ServerName' AND DatabaseName = '$DatabaseName';"
WHERE TenantId = $rawkeyHexString;"

Invoke-SqlAzureWithRetry `
-ServerInstance $Catalog.FullyQualifiedServerName `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if ($DemoScenario -eq 1)
{
Write-Output "Running ticket generator ..."

& $PSScriptRoot\..\..\Utilities\TicketGenerator.ps1 `
& $PSScriptRoot\..\..\Utilities\TicketGenerator2.ps1 `
-WtpResourceGroupName $wtpUser.ResourceGroupName `
-WtpUser $wtpUser.Name
exit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,81 +5,67 @@ select * from sys.external_tables;
GO

-- *******************************************************
-- SOME ADHOC QUERIES. Any others you would like to try?
-- SAMPLE QUERIES
-- *******************************************************

-- What venues are registered on the Wingtip platform right now?
-- Which venues are currently registered on the Wingtip platform?
SELECT VenueName,
VenueType
FROM dbo.Venue
FROM dbo.VenuesGlobal

GO

-- What are the most popular venue types?
SELECT VenueType,
Count(TicketPurchaseId) AS PurchasedTicketCount
FROM dbo.Venue
INNER JOIN dbo.TicketPurchases ON TicketPurchaseId > 0
Count(TicketId) AS PurchasedTicketCount
FROM dbo.VenuesGlobal
INNER JOIN dbo.VenueTickets ON VenuesGlobal.VenueId = VenueTickets.VenueId
GROUP BY VenueType
ORDER BY PurchasedTicketCount DESC

GO

-- Which day had the most tickets sold?
SELECT CAST(PurchaseDate AS DATE) AS TicketPurchaseDate,
Count(TicketPurchaseId) AS TicketCount
FROM TicketPurchases
GROUP BY PurchaseDate
ORDER BY TicketCount DESC, TicketPurchaseDate ASC
-- On which day were the most tickets sold?
SELECT CAST(PurchaseDate AS DATE) AS TicketPurchaseDate,
Count(TicketId) AS TicketCount
FROM VenueTicketPurchases
INNER JOIN VenueTickets ON (VenueTickets.TicketPurchaseId = VenueTicketPurchases.TicketPurchaseId AND VenueTickets.VenueId = VenueTicketPurchases.VenueId)
GROUP BY (CAST(PurchaseDate AS DATE))
ORDER BY TicketCount DESC, TicketPurchaseDate ASC

GO

-- What was the highest revenue event per each venue?
-- Which event had the highest revenue at each venue?
EXEC sp_execute_remote
N'WtpTenantDBs',
N'SELECT TOP (1)
VenueName,
EventName,
SUM(PurchaseTotal) AS PurchaseTotal
FROM Venue
INNER JOIN Events ON Events.EventId > 0
INNER JOIN Tickets ON Tickets.EventId = Events.EventId
INNER JOIN TicketPurchases ON TicketPurchases.TicketPurchaseId = Tickets.TicketPurchaseId
GROUP BY VenueName, EventName
'
Subtitle AS Performers,
COUNT(TicketId) AS TicketsSold,
CONVERT(VARCHAR(30), SUM(PurchaseTotal), 1) AS PurchaseTotal
FROM VenueEvents
INNER JOIN VenueTickets ON VenueTickets.EventId = VenueEvents.EventId
INNER JOIN VenueTicketPurchases ON VenueTicketPurchases.TicketPurchaseId = VenueTickets.TicketPurchaseId
INNER JOIN VenuesGlobal ON VenueEvents.VenueId = VenuesGlobal.VenueId
GROUP BY VenueName, EventName, Subtitle
ORDER BY PurchaseTotal DESC'

GO

-- What are the top 10 grossing events across all venues on the WTP platform

--Create temp table to hold the highest revenue events from each venue
DROP TABLE IF EXISTS #tmpMaxRevenue
CREATE TABLE #tmpMaxRevenue (VenueName nvarchar(50), EventName nvarchar(50), PurchaseTotal money, ShardName nvarchar(200))
INSERT INTO #tmpMaxRevenue (VenueName, EventName, PurchaseTotal, ShardName)
EXEC sp_execute_remote
N'WtpTenantDBs',
N'SELECT TOP (10)
(SELECT TOP (1) VenueName FROM Venue) AS VenueName,
EventName,
SUM(PurchaseTotal) AS PurchaseTotal
FROM Events
INNER JOIN Tickets ON Tickets.EventId = Events.EventId
INNER JOIN TicketPurchases ON TicketPurchases.TicketPurchaseId = Tickets.TicketPurchaseId
GROUP BY EventName
ORDER BY PurchaseTotal DESC'

-- Select highest grossing events. Reference event revenue temp table from above
SELECT TOP (10)
VenueName,
EventName,
PurchaseTotal
FROM #tmpMaxRevenue
GROUP BY VenueName, PurchaseTotal, EventName
ORDER BY PurchaseTotal DESC, EventName

GO





EventName,
Subtitle AS EventPerformers,
CAST(VenueEvents.Date AS DATE) AS EventDate,
COUNT(TicketId) AS TicketPurchaseCount,
CONVERT(VARCHAR(30), SUM(PurchaseTotal), 1) AS EventRevenue
FROM VenueEvents
INNER JOIN VenueTickets ON (VenueTickets.EventId = VenueEvents.EventId AND VenueTickets.VenueId = VenueEvents.VenueId)
INNER JOIN VenueTicketPurchases ON (VenueTicketPurchases.TicketPurchaseId = VenueTickets.TicketPurchaseId AND VenueTicketPurchases.VenueId = VenueEvents.VenueId)
INNER JOIN VenuesGlobal ON VenueEvents.VenueId = VenuesGlobal.VenueId
GROUP BY VenueName, Subtitle, EventName, (CAST(VenueEvents.Date AS DATE))
ORDER BY SUM(PurchaseTotal) DESC

GO
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ $commandText = "
CREATE EXTERNAL TABLE [dbo].[Venue] (
[VenueName] NVARCHAR (50) NOT NULL,
[VenueType] CHAR (30) NOT NULL,
[AdminEmail] NCHAR (30) NOT NULL,
[AdminEmail] VARCHAR (50) NOT NULL,
[AdminPassword] NCHAR (30) NULL,
[PostalCode] CHAR (10) NULL,
[CountryCode] CHAR (3) NOT NULL
Expand Down Expand Up @@ -187,16 +187,16 @@ $commandText = "
INSERT INTO [dbo].[VenueTypes]
([VenueType],[VenueTypeName],[EventTypeName],[EventTypeShortName],[EventTypeShortNamePlural],[Language])
VALUES
('MultiPurposeVenue','Multi Purpose Venue','Event', 'Event','Events','en-us'),
('ClassicalConcertHall','Classical Concert Hall','Classical Concert','Concert','Concerts','en-us'),
('JazzClub','Jazz Club','Jazz Session','Session','Sessions','en-us'),
('JudoClub','Judo Club','Judo Tournament','Tournament','Tournaments','en-us'),
('SoccerClub','Soccer Club','Soccer Match', 'Match','Matches','en-us'),
('MotorRacing','Motor Racing','Car Race', 'Race','Races','en-us'),
('DanceStudio', 'Dance Studio', 'Performance', 'Performance', 'Performances','en-us'),
('BluesClub', 'Blues Club', 'Blues Session', 'Session','Sessions','en-us' ),
('RockMusicVenue','Rock Music Venue','Rock Concert','Concert', 'Concerts','en-us'),
('Opera','Opera','Opera','Opera','Operas','en-us');
('multipurpose','Multi-Purpose','Event', 'Event','Events','en-us'),
('classicalmusic','Classical Music ','Classical Concert','Concert','Concerts','en-us'),
('jazz','Jazz','Jazz Session','Session','Sessions','en-us'),
('judo','Judo','Judo Tournament','Tournament','Tournaments','en-us'),
('soccer','Soccer','Soccer Match', 'Match','Matches','en-us'),
('motorracing','Motor Racing','Car Race', 'Race','Races','en-us'),
('dance', 'Dance', 'Performance', 'Performance', 'Performances','en-us'),
('blues', 'Blues', 'Blues Session', 'Session','Sessions','en-us' ),
('rockmusic','Rock Music','Rock Concert','Concert', 'Concerts','en-us'),
('opera','Opera','Opera','Opera','Operas','en-us');
GO
PRINT N'Update complete.';
Expand Down
Loading

0 comments on commit 86084c5

Please sign in to comment.