@@ -3,10 +3,11 @@ package main
33import (
44 "time"
55
6+ "github.com/google/uuid"
67 "github.com/ydb-platform/ydb-go-sdk/v3/table/types"
78)
89
9- func seriesData (id uint64 , released time.Time , title , info , comment string ) types.Value {
10+ func seriesData (id string , released time.Time , title , info , comment string ) types.Value {
1011 var commentv types.Value
1112 if comment == "" {
1213 commentv = types .NullValue (types .TypeUTF8 )
@@ -15,143 +16,189 @@ func seriesData(id uint64, released time.Time, title, info, comment string) type
1516 }
1617
1718 return types .StructValue (
18- types .StructFieldValue ("series_id" , types .Uint64Value (id )),
19+ types .StructFieldValue ("series_id" , types .BytesValueFromString (id )),
1920 types .StructFieldValue ("release_date" , types .DateValueFromTime (released )),
2021 types .StructFieldValue ("title" , types .TextValue (title )),
2122 types .StructFieldValue ("series_info" , types .TextValue (info )),
2223 types .StructFieldValue ("comment" , commentv ),
2324 )
2425}
2526
26- func seasonData (seriesID , seasonID uint64 , title string , first , last time.Time ) types.Value {
27+ func seasonData (seriesID , seasonID , title string , first , last time.Time ) types.Value {
2728 return types .StructValue (
28- types .StructFieldValue ("series_id" , types .Uint64Value (seriesID )),
29- types .StructFieldValue ("season_id" , types .Uint64Value (seasonID )),
29+ types .StructFieldValue ("series_id" , types .BytesValueFromString (seriesID )),
30+ types .StructFieldValue ("season_id" , types .BytesValueFromString (seasonID )),
3031 types .StructFieldValue ("title" , types .TextValue (title )),
3132 types .StructFieldValue ("first_aired" , types .DateValueFromTime (first )),
3233 types .StructFieldValue ("last_aired" , types .DateValueFromTime (last )),
3334 )
3435}
3536
36- func episodeData (seriesID , seasonID , episodeID uint64 , title string , date time.Time ) types.Value {
37+ func episodeData (seriesID , seasonID , episodeID , title string , date time.Time ) types.Value {
3738 return types .StructValue (
38- types .StructFieldValue ("series_id" , types .Uint64Value (seriesID )),
39- types .StructFieldValue ("season_id" , types .Uint64Value (seasonID )),
40- types .StructFieldValue ("episode_id" , types .Uint64Value (episodeID )),
39+ types .StructFieldValue ("series_id" , types .BytesValueFromString (seriesID )),
40+ types .StructFieldValue ("season_id" , types .BytesValueFromString (seasonID )),
41+ types .StructFieldValue ("episode_id" , types .BytesValueFromString (episodeID )),
4142 types .StructFieldValue ("title" , types .TextValue (title )),
4243 types .StructFieldValue ("air_date" , types .DateValueFromTime (date )),
4344 )
4445}
4546
46- func getSeriesData () types.Value {
47- return types .ListValue (
48- seriesData (
49- 1 , days ("2006-02-03" ), "IT Crowd" , "" +
50- "The IT Crowd is a British sitcom produced by Channel 4, written by Graham Linehan, produced by " +
51- "Ash Atalla and starring Chris O'Dowd, Richard Ayoade, Katherine Parkinson, and Matt Berry." ,
52- "" , // NULL comment.
53- ),
54- seriesData (
55- 2 , days ("2014-04-06" ), "Silicon Valley" , "" +
56- "Silicon Valley is an American comedy television series created by Mike Judge, John Altschuler and " +
57- "Dave Krinsky. The series focuses on five young men who founded a startup company in Silicon Valley." ,
58- "Some comment here" ,
59- ),
60- )
47+ func getData () (series , seasons , episodes []types.Value ) {
48+ for seriesID , fill := range map [string ]func (seriesID string ) (
49+ seriesData types.Value , seasons []types.Value , episodes []types.Value ,
50+ ){
51+ uuid .New ().String (): getDataForITCrowd ,
52+ uuid .New ().String (): getDataForSiliconValley ,
53+ } {
54+ seriesData , seasonsData , episodesData := fill (seriesID )
55+ series = append (series , seriesData )
56+ seasons = append (seasons , seasonsData ... )
57+ episodes = append (episodes , episodesData ... )
58+ }
59+
60+ return
6161}
6262
63- func getSeasonsData () types.Value {
64- return types .ListValue (
65- seasonData (1 , 1 , "Season 1" , days ("2006-02-03" ), days ("2006-03-03" )),
66- seasonData (1 , 2 , "Season 2" , days ("2007-08-24" ), days ("2007-09-28" )),
67- seasonData (1 , 3 , "Season 3" , days ("2008-11-21" ), days ("2008-12-26" )),
68- seasonData (1 , 4 , "Season 4" , days ("2010-06-25" ), days ("2010-07-30" )),
69- seasonData (2 , 1 , "Season 1" , days ("2014-04-06" ), days ("2014-06-01" )),
70- seasonData (2 , 2 , "Season 2" , days ("2015-04-12" ), days ("2015-06-14" )),
71- seasonData (2 , 3 , "Season 3" , days ("2016-04-24" ), days ("2016-06-26" )),
72- seasonData (2 , 4 , "Season 4" , days ("2017-04-23" ), days ("2017-06-25" )),
73- seasonData (2 , 5 , "Season 5" , days ("2018-03-25" ), days ("2018-05-13" )),
63+ func getDataForITCrowd (seriesID string ) (series types.Value , seasons , episodes []types.Value ) {
64+ series = seriesData (
65+ seriesID , date ("2006-02-03" ), "IT Crowd" , "" +
66+ "The IT Crowd is a British sitcom produced by Channel 4, written by Graham Linehan, produced by " +
67+ "Ash Atalla and starring Chris O'Dowd, Richard Ayoade, Katherine Parkinson, and Matt Berry." ,
68+ "" , // NULL comment.
7469 )
70+ for _ , season := range []struct { //nolint:gocritic
71+ title string
72+ first time.Time
73+ last time.Time
74+ episodes map [string ]time.Time
75+ }{
76+ {"Season 1" , date ("2006-02-03" ), date ("2006-03-03" ), map [string ]time.Time {
77+ "Yesterday's Jam" : date ("2006-02-03" ),
78+ "Calamity Jen" : date ("2006-02-03" ),
79+ "Fifty-Fifty" : date ("2006-02-10" ),
80+ "The Red Door" : date ("2006-02-17" ),
81+ "The Haunting of Bill Crouse" : date ("2006-02-24" ),
82+ "Aunt Irma Visits" : date ("2006-03-03" ),
83+ }},
84+ {"Season 2" , date ("2007-08-24" ), date ("2007-09-28" ), map [string ]time.Time {
85+ "The Work Outing" : date ("2006-08-24" ),
86+ "Return of the Golden Child" : date ("2007-08-31" ),
87+ "Moss and the German" : date ("2007-09-07" ),
88+ "The Dinner Party" : date ("2007-09-14" ),
89+ "Smoke and Mirrors" : date ("2007-09-21" ),
90+ "Men Without Women" : date ("2007-09-28" ),
91+ }},
92+ {"Season 3" , date ("2008-11-21" ), date ("2008-12-26" ), map [string ]time.Time {
93+ "From Hell" : date ("2008-11-21" ),
94+ "Are We Not Men?" : date ("2008-11-28" ),
95+ "Tramps Like Us" : date ("2008-12-05" ),
96+ "The Speech" : date ("2008-12-12" ),
97+ "Friendface" : date ("2008-12-19" ),
98+ "Calendar Geeks" : date ("2008-12-26" ),
99+ }},
100+ {"Season 4" , date ("2010-06-25" ), date ("2010-07-30" ), map [string ]time.Time {
101+ "Jen The Fredo" : date ("2010-06-25" ),
102+ "The Final Countdown" : date ("2010-07-02" ),
103+ "Something Happened" : date ("2010-07-09" ),
104+ "Italian For Beginners" : date ("2010-07-16" ),
105+ "Bad Boys" : date ("2010-07-23" ),
106+ "Reynholm vs Reynholm" : date ("2010-07-30" ),
107+ }},
108+ } {
109+ seasonID := uuid .New ().String ()
110+ seasons = append (seasons , seasonData (seriesID , seasonID , season .title , season .first , season .last ))
111+ for title , date := range season .episodes {
112+ episodes = append (episodes , episodeData (seriesID , seasonID , uuid .New ().String (), title , date ))
113+ }
114+ }
115+
116+ return series , seasons , episodes
75117}
76118
77- func getEpisodesData () types.Value {
78- return types .ListValue (
79- episodeData (1 , 1 , 1 , "Yesterday's Jam" , days ("2006-02-03" )),
80- episodeData (1 , 1 , 2 , "Calamity Jen" , days ("2006-02-03" )),
81- episodeData (1 , 1 , 3 , "Fifty-Fifty" , days ("2006-02-10" )),
82- episodeData (1 , 1 , 4 , "The Red Door" , days ("2006-02-17" )),
83- episodeData (1 , 1 , 5 , "The Haunting of Bill Crouse" , days ("2006-02-24" )),
84- episodeData (1 , 1 , 6 , "Aunt Irma Visits" , days ("2006-03-03" )),
85- episodeData (1 , 2 , 1 , "The Work Outing" , days ("2006-08-24" )),
86- episodeData (1 , 2 , 2 , "Return of the Golden Child" , days ("2007-08-31" )),
87- episodeData (1 , 2 , 3 , "Moss and the German" , days ("2007-09-07" )),
88- episodeData (1 , 2 , 4 , "The Dinner Party" , days ("2007-09-14" )),
89- episodeData (1 , 2 , 5 , "Smoke and Mirrors" , days ("2007-09-21" )),
90- episodeData (1 , 2 , 6 , "Men Without Women" , days ("2007-09-28" )),
91- episodeData (1 , 3 , 1 , "From Hell" , days ("2008-11-21" )),
92- episodeData (1 , 3 , 2 , "Are We Not Men?" , days ("2008-11-28" )),
93- episodeData (1 , 3 , 3 , "Tramps Like Us" , days ("2008-12-05" )),
94- episodeData (1 , 3 , 4 , "The Speech" , days ("2008-12-12" )),
95- episodeData (1 , 3 , 5 , "Friendface" , days ("2008-12-19" )),
96- episodeData (1 , 3 , 6 , "Calendar Geeks" , days ("2008-12-26" )),
97- episodeData (1 , 4 , 1 , "Jen The Fredo" , days ("2010-06-25" )),
98- episodeData (1 , 4 , 2 , "The Final Countdown" , days ("2010-07-02" )),
99- episodeData (1 , 4 , 3 , "Something Happened" , days ("2010-07-09" )),
100- episodeData (1 , 4 , 4 , "Italian For Beginners" , days ("2010-07-16" )),
101- episodeData (1 , 4 , 5 , "Bad Boys" , days ("2010-07-23" )),
102- episodeData (1 , 4 , 6 , "Reynholm vs Reynholm" , days ("2010-07-30" )),
103- episodeData (2 , 1 , 1 , "Minimum Viable Product" , days ("2014-04-06" )),
104- episodeData (2 , 1 , 2 , "The Cap Table" , days ("2014-04-13" )),
105- episodeData (2 , 1 , 3 , "Articles of Incorporation" , days ("2014-04-20" )),
106- episodeData (2 , 1 , 4 , "Fiduciary Duties" , days ("2014-04-27" )),
107- episodeData (2 , 1 , 5 , "Signaling Risk" , days ("2014-05-04" )),
108- episodeData (2 , 1 , 6 , "Third Party Insourcing" , days ("2014-05-11" )),
109- episodeData (2 , 1 , 7 , "Proof of Concept" , days ("2014-05-18" )),
110- episodeData (2 , 1 , 8 , "Optimal Tip-to-Tip Efficiency" , days ("2014-06-01" )),
111- episodeData (2 , 2 , 1 , "Sand Hill Shuffle" , days ("2015-04-12" )),
112- episodeData (2 , 2 , 2 , "Runaway Devaluation" , days ("2015-04-19" )),
113- episodeData (2 , 2 , 3 , "Bad Money" , days ("2015-04-26" )),
114- episodeData (2 , 2 , 4 , "The Lady" , days ("2015-05-03" )),
115- episodeData (2 , 2 , 5 , "Server Space" , days ("2015-05-10" )),
116- episodeData (2 , 2 , 6 , "Homicide" , days ("2015-05-17" )),
117- episodeData (2 , 2 , 7 , "Adult Content" , days ("2015-05-24" )),
118- episodeData (2 , 2 , 8 , "White Hat/Black Hat" , days ("2015-05-31" )),
119- episodeData (2 , 2 , 9 , "Binding Arbitration" , days ("2015-06-07" )),
120- episodeData (2 , 2 , 10 , "Two Days of the Condor" , days ("2015-06-14" )),
121- episodeData (2 , 3 , 1 , "Founder Friendly" , days ("2016-04-24" )),
122- episodeData (2 , 3 , 2 , "Two in the Box" , days ("2016-05-01" )),
123- episodeData (2 , 3 , 3 , "Meinertzhagen's Haversack" , days ("2016-05-08" )),
124- episodeData (2 , 3 , 4 , "Maleant Data Systems Solutions" , days ("2016-05-15" )),
125- episodeData (2 , 3 , 5 , "The Empty Chair" , days ("2016-05-22" )),
126- episodeData (2 , 3 , 6 , "Bachmanity Insanity" , days ("2016-05-29" )),
127- episodeData (2 , 3 , 7 , "To Build a Better Beta" , days ("2016-06-05" )),
128- episodeData (2 , 3 , 8 , "Bachman's Earnings Over-Ride" , days ("2016-06-12" )),
129- episodeData (2 , 3 , 9 , "Daily Active Users" , days ("2016-06-19" )),
130- episodeData (2 , 3 , 10 , "The Uptick" , days ("2016-06-26" )),
131- episodeData (2 , 4 , 1 , "Success Failure" , days ("2017-04-23" )),
132- episodeData (2 , 4 , 2 , "Terms of Service" , days ("2017-04-30" )),
133- episodeData (2 , 4 , 3 , "Intellectual Property" , days ("2017-05-07" )),
134- episodeData (2 , 4 , 4 , "Teambuilding Exercise" , days ("2017-05-14" )),
135- episodeData (2 , 4 , 5 , "The Blood Boy" , days ("2017-05-21" )),
136- episodeData (2 , 4 , 6 , "Customer Service" , days ("2017-05-28" )),
137- episodeData (2 , 4 , 7 , "The Patent Troll" , days ("2017-06-04" )),
138- episodeData (2 , 4 , 8 , "The Keenan Vortex" , days ("2017-06-11" )),
139- episodeData (2 , 4 , 9 , "Hooli-Con" , days ("2017-06-18" )),
140- episodeData (2 , 4 , 10 , "Server Error" , days ("2017-06-25" )),
141- episodeData (2 , 5 , 1 , "Grow Fast or Die Slow" , days ("2018-03-25" )),
142- episodeData (2 , 5 , 2 , "Reorientation" , days ("2018-04-01" )),
143- episodeData (2 , 5 , 3 , "Chief Operating Officer" , days ("2018-04-08" )),
144- episodeData (2 , 5 , 4 , "Tech Evangelist" , days ("2018-04-15" )),
145- episodeData (2 , 5 , 5 , "Facial Recognition" , days ("2018-04-22" )),
146- episodeData (2 , 5 , 6 , "Artificial Emotional Intelligence" , days ("2018-04-29" )),
147- episodeData (2 , 5 , 7 , "Initial Coin Offering" , days ("2018-05-06" )),
148- episodeData (2 , 5 , 8 , "Fifty-One Percent" , days ("2018-05-13" )),
119+ func getDataForSiliconValley (seriesID string ) (series types.Value , seasons , episodes []types.Value ) {
120+ series = seriesData (
121+ seriesID , date ("2014-04-06" ), "Silicon Valley" , "" +
122+ "Silicon Valley is an American comedy television series created by Mike Judge, John Altschuler and " +
123+ "Dave Krinsky. The series focuses on five young men who founded a startup company in Silicon Valley." ,
124+ "Some comment here" ,
149125 )
126+ for _ , season := range []struct { //nolint:gocritic
127+ title string
128+ first time.Time
129+ last time.Time
130+ episodes map [string ]time.Time
131+ }{
132+ {"Season 1" , date ("2006-02-03" ), date ("2006-03-03" ), map [string ]time.Time {
133+ "Minimum Viable Product" : date ("2014-04-06" ),
134+ "The Cap Table" : date ("2014-04-13" ),
135+ "Articles of Incorporation" : date ("2014-04-20" ),
136+ "Fiduciary Duties" : date ("2014-04-27" ),
137+ "Signaling Risk" : date ("2014-05-04" ),
138+ "Third Party Insourcing" : date ("2014-05-11" ),
139+ "Proof of Concept" : date ("2014-05-18" ),
140+ "Optimal Tip-to-Tip Efficiency" : date ("2014-06-01" ),
141+ }},
142+ {"Season 2" , date ("2007-08-24" ), date ("2007-09-28" ), map [string ]time.Time {
143+ "Sand Hill Shuffle" : date ("2015-04-12" ),
144+ "Runaway Devaluation" : date ("2015-04-19" ),
145+ "Bad Money" : date ("2015-04-26" ),
146+ "The Lady" : date ("2015-05-03" ),
147+ "Server Space" : date ("2015-05-10" ),
148+ "Homicide" : date ("2015-05-17" ),
149+ "Adult Content" : date ("2015-05-24" ),
150+ "White Hat/Black Hat" : date ("2015-05-31" ),
151+ "Binding Arbitration" : date ("2015-06-07" ),
152+ "Two Days of the Condor" : date ("2015-06-14" ),
153+ }},
154+ {"Season 3" , date ("2008-11-21" ), date ("2008-12-26" ), map [string ]time.Time {
155+ "Founder Friendly" : date ("2016-04-24" ),
156+ "Two in the Box" : date ("2016-05-01" ),
157+ "Meinertzhagen's Haversack" : date ("2016-05-08" ),
158+ "Maleant Data Systems Solutions" : date ("2016-05-15" ),
159+ "The Empty Chair" : date ("2016-05-22" ),
160+ "Bachmanity Insanity" : date ("2016-05-29" ),
161+ "To Build a Better Beta" : date ("2016-06-05" ),
162+ "Bachman's Earnings Over-Ride" : date ("2016-06-12" ),
163+ "Daily Active Users" : date ("2016-06-19" ),
164+ "The Uptick" : date ("2016-06-26" ),
165+ }},
166+ {"Season 4" , date ("2010-06-25" ), date ("2010-07-30" ), map [string ]time.Time {
167+ "Success Failure" : date ("2017-04-23" ),
168+ "Terms of Service" : date ("2017-04-30" ),
169+ "Intellectual Property" : date ("2017-05-07" ),
170+ "Teambuilding Exercise" : date ("2017-05-14" ),
171+ "The Blood Boy" : date ("2017-05-21" ),
172+ "Customer Service" : date ("2017-05-28" ),
173+ "The Patent Troll" : date ("2017-06-04" ),
174+ "The Keenan Vortex" : date ("2017-06-11" ),
175+ "Hooli-Con" : date ("2017-06-18" ),
176+ "Server Error" : date ("2017-06-25" ),
177+ }},
178+ {"Season 5" , date ("2018-03-25" ), date ("2018-05-13" ), map [string ]time.Time {
179+ "Grow Fast or Die Slow" : date ("2018-03-25" ),
180+ "Reorientation" : date ("2018-04-01" ),
181+ "Chief Operating Officer" : date ("2018-04-08" ),
182+ "Tech Evangelist" : date ("2018-04-15" ),
183+ "Facial Recognition" : date ("2018-04-22" ),
184+ "Artificial Emotional Intelligence" : date ("2018-04-29" ),
185+ "Initial Coin Offering" : date ("2018-05-06" ),
186+ "Fifty-One Percent" : date ("2018-05-13" ),
187+ }},
188+ } {
189+ seasonID := uuid .New ().String ()
190+ seasons = append (seasons , seasonData (seriesID , seasonID , season .title , season .first , season .last ))
191+ for title , date := range season .episodes {
192+ episodes = append (episodes , episodeData (seriesID , seasonID , uuid .New ().String (), title , date ))
193+ }
194+ }
195+
196+ return series , seasons , episodes
150197}
151198
152199const dateISO8601 = "2006-01-02"
153200
154- func days (date string ) time.Time {
201+ func date (date string ) time.Time {
155202 t , err := time .Parse (dateISO8601 , date )
156203 if err != nil {
157204 panic (err )
0 commit comments