@@ -130,28 +130,10 @@ export async function uploadManifest(
130
130
}
131
131
}
132
132
133
- interface ScheduleItem {
134
- ttl : Date ;
135
- ref : string ;
136
- paths : Record < string , string > ;
137
- }
138
-
139
- function createScheduleItem (
140
- manifest : Manifest ,
141
- manifestPaths : Record < string , string > ,
142
- ttl : Date
143
- ) {
144
- return {
145
- ttl : ttl ,
146
- ref : manifest . ref ,
147
- paths : manifestPaths ,
148
- } as ScheduleItem ;
149
- }
150
-
151
133
async function saveManifestEntity ( key : entity . Key , data : any ) {
152
134
const ent = {
153
135
key : key ,
154
- excludeFromIndexes : [ 'schedule ' ] ,
136
+ excludeFromIndexes : [ 'paths ' ] ,
155
137
data : data ,
156
138
} ;
157
139
await datastore . save ( ent ) ;
@@ -161,56 +143,39 @@ async function finalize(manifest: Manifest, ttl?: Date) {
161
143
const manifestPaths = manifest . toJSON ( ) ;
162
144
const now = new Date ( ) ;
163
145
164
- // Create shortSha mapping.
146
+ // Create shortSha mapping for staging .
165
147
const key = datastore . key ( [
166
148
'Fileset2Manifest' ,
167
149
`${ manifest . site } :ref:${ manifest . shortSha } ` ,
168
150
] ) ;
169
- const scheduleItem = createScheduleItem ( manifest , manifestPaths , now ) ;
170
- const schedule : Record < string , ScheduleItem > = { } ;
171
- schedule [ now . toString ( ) ] = scheduleItem ;
172
151
await saveManifestEntity ( key , {
173
152
site : manifest . site ,
174
153
ref : manifest . ref ,
175
154
branch : manifest . branch ,
176
- schedule : schedule ,
155
+ paths : manifestPaths ,
177
156
} ) ;
178
157
179
- // Create branch mapping.
158
+ // Create branch mapping for staging .
180
159
if ( manifest . branch ) {
181
160
const branchKey = datastore . key ( [
182
161
'Fileset2Manifest' ,
183
162
`${ manifest . site } :branch:${ manifest . branch } ` ,
184
163
] ) ;
185
- const branchScheduleItem = createScheduleItem (
186
- manifest ,
187
- manifestPaths ,
188
- ttl || now
189
- ) ;
190
- const branchSchedule : Record < string , ScheduleItem > = { } ;
191
- const branchScheduleKey = ( ttl || now ) . toString ( ) ;
192
- branchSchedule [ branchScheduleKey ] = branchScheduleItem ;
193
- const resp = await datastore . get ( branchKey ) ;
194
- let existingData = resp && resp [ 0 ] ;
195
- if ( ! existingData ) {
196
- existingData = {
197
- site : manifest . site ,
198
- ref : manifest . ref ,
199
- branch : manifest . branch ,
200
- schedule : branchSchedule ,
201
- } ;
202
- } else {
203
- // TODO: Clean up past scheduled items here.
204
- existingData . schedule [ branchScheduleKey ] = branchScheduleItem ;
205
- }
206
- console . log (
207
- `TTLs for branch: ${ manifest . branch } -> ${ Object . keys (
208
- existingData . schedule
209
- ) } `
210
- ) ;
211
- await saveManifestEntity ( branchKey , existingData ) ;
164
+ await saveManifestEntity ( branchKey , {
165
+ site : manifest . site ,
166
+ ref : manifest . ref ,
167
+ branch : manifest . branch ,
168
+ paths : manifestPaths ,
169
+ } ) ;
212
170
}
213
171
172
+ // TODO: Update the site's playbook and use the playbook for timed launches.
173
+ // The playbook should contain copies of all future launches. Each site should only
174
+ // have one playbook.
175
+ // const routerKey = datastore.key(['Fileset2Router', manifest.site]);
176
+ // const router = await datastore.get(routerKey);
177
+ // const entity = router && router[0];
178
+
214
179
console . log (
215
180
`Finalized upload for site: ${ manifest . site } -> ${ manifest . branch } @ ${ manifest . shortSha } `
216
181
) ;
0 commit comments