mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2025-12-27 10:33:59 -05:00
Store shortlinks with both 6 and 9 character prefixs in dynamodb
This commit is contained in:
@@ -74,6 +74,20 @@ export class StorageS3 extends StorageBase {
|
||||
creation_date: {S: now.toISOString()},
|
||||
},
|
||||
}).promise(),
|
||||
// temporary extra store with 6 character prefix for #2582
|
||||
this.dynamoDb.putItem({
|
||||
TableName: this.table,
|
||||
Item: {
|
||||
prefix: {S: item.prefix.substring(0, 6)},
|
||||
unique_subhash: {S: item.uniqueSubHash},
|
||||
full_hash: {S: item.fullHash},
|
||||
stats: {
|
||||
M: {clicks: {N: '0'}},
|
||||
},
|
||||
creation_ip: {S: ip},
|
||||
creation_date: {S: now.toISOString()},
|
||||
},
|
||||
}).promise(),
|
||||
this.s3.put(item.fullHash, item.config, this.prefix, {}),
|
||||
]);
|
||||
return item;
|
||||
|
||||
@@ -151,13 +151,13 @@ describe('Stores to s3', () => {
|
||||
it('and works ok', () => {
|
||||
const storage = new StorageS3(httpRootDir, compilerProps, awsProps);
|
||||
const object = {
|
||||
prefix: 'ABCDEF',
|
||||
prefix: 'ABCDEFG',
|
||||
uniqueSubHash: 'ABCDEFG',
|
||||
fullHash: 'ABCDEFGHIJKLMNOP',
|
||||
config: 'yo',
|
||||
};
|
||||
|
||||
const ran = {s3: false, dynamo: false};
|
||||
const ran = {s3: false, dynamo: 0};
|
||||
s3PutObjectHandlers.push((q) => {
|
||||
q.Bucket.should.equal('bucket');
|
||||
q.Key.should.equal('prefix/ABCDEFGHIJKLMNOP');
|
||||
@@ -165,6 +165,20 @@ describe('Stores to s3', () => {
|
||||
ran.s3 = true;
|
||||
return {};
|
||||
});
|
||||
dynamoDbPutItemHandlers.push((q) => {
|
||||
q.TableName.should.equals('table');
|
||||
q.Item.should.deep.equals({
|
||||
prefix: {S: 'ABCDEFG'},
|
||||
unique_subhash: {S: 'ABCDEFG'},
|
||||
full_hash: {S: 'ABCDEFGHIJKLMNOP'},
|
||||
stats: {M: {clicks: {N: '0'}}},
|
||||
creation_ip: {S: 'localhost'},
|
||||
// Cheat the date
|
||||
creation_date: {S: q.Item.creation_date.S},
|
||||
});
|
||||
ran.dynamo += 1;
|
||||
return {};
|
||||
});
|
||||
dynamoDbPutItemHandlers.push((q) => {
|
||||
q.TableName.should.equals('table');
|
||||
q.Item.should.deep.equals({
|
||||
@@ -176,11 +190,11 @@ describe('Stores to s3', () => {
|
||||
// Cheat the date
|
||||
creation_date: {S: q.Item.creation_date.S},
|
||||
});
|
||||
ran.dynamo = true;
|
||||
ran.dynamo += 1;
|
||||
return {};
|
||||
});
|
||||
return storage.storeItem(object, {get: () => 'localhost'}).then(() => {
|
||||
ran.should.deep.equal({s3: true, dynamo: true});
|
||||
ran.should.deep.equal({s3: true, dynamo: 2});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user