Skip to content

Commit

Permalink
Merge branch 'master' into DOP-4209
Browse files Browse the repository at this point in the history
  • Loading branch information
mayaraman19 authored Jan 22, 2024
2 parents fc56fc7 + effa134 commit bb41a5f
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-persistence.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v1
with:
node-version: '14.x'
node-version: '18.x'
- name: Install dependencies
run: npm install --dev
- name: Lint
Expand Down
6 changes: 6 additions & 0 deletions infrastructure/ecs-main/buckets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ Resources:
Protocol: "https"
HostName: ${self:custom.site.host.${self:provider.stage}}
ReplaceKeyPrefixWith: ${self:custom.site.prefix.${self:provider.stage}}/atlas/cli/v1.1
- RoutingRuleCondition:
KeyPrefixEquals: ${self:custom.site.prefix.${self:provider.stage}}/php-library/master
RedirectRule:
Protocol: "https"
HostName: ${self:custom.site.host.${self:provider.stage}}
ReplaceKeyPrefixWith: ${self:custom.site.prefix.${self:provider.stage}}/php-library/upcoming
DocAtlasBucket:
Type: "AWS::S3::Bucket"
Properties:
Expand Down
2 changes: 1 addition & 1 deletion modules/persistence/.nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v14.17.6
v18.12.0
11 changes: 7 additions & 4 deletions modules/persistence/src/services/metadata/ToC/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { AssociatedProduct, hasAssociations } from '../associated_products';
import { Metadata } from '..';
import { convertSlugToUrl } from './utils/convertSlugToUrl';

Expand Down Expand Up @@ -93,15 +92,19 @@ const mergeTocTreeOrder = (metadata: Metadata, node, insertions: TocOrderInserti
// contains an associated_products entry
export const traverseAndMerge = (
metadata: Metadata,
associated_products: AssociatedProduct[],
umbrellaMetadata: Metadata,
umbrellaToCs: ToCCopies,
tocInsertions: ToCInsertions,
tocOrderInsertions: TocOrderInsertions
) => {
const { project } = metadata;
const associatedProducts = umbrellaMetadata.associated_products || [];

const toctree = hasAssociations(metadata) ? umbrellaToCs.original : umbrellaToCs.urlified;
const toBeInserted = new Set(associated_products.map((p) => p.name));
const associatedProductNames = associatedProducts.map((p) => p.name);
const toctree = structuredClone(
metadata.project === umbrellaMetadata.project ? umbrellaToCs.original : umbrellaToCs.urlified
);
const toBeInserted = new Set(associatedProductNames);
let queue = [toctree];
while (queue?.length && toBeInserted.size) {
let next = queue.shift();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ interface AggregatedMetadata {
most_recent: Metadata;
}

type EnvKeyedObject = {
prd: any;
preprd: any;
dotcomstg: any;
dotcomprd: any;
};
// TODO: move the branch/repobranch interfaces into their own file, or into a seperate abstraction?
export interface BranchEntry {
name: string;
Expand Down Expand Up @@ -69,8 +63,8 @@ const umbrellaMetadataEntry = async (project: string): Promise<Metadata> => {
return null as unknown as Metadata;
}

const repoDoc = await getRepoBranchesEntry(project);
const branchNames = repoDoc.branches.map((branchEntry) => branchEntry.gitBranchName);
const umbrellaRepos = await getRepoBranchesEntry(umbrella.project);
const branchNames = umbrellaRepos.branches.map((branchEntry) => branchEntry.gitBranchName);
const entry = await snooty
.collection('metadata')
.find({
Expand Down Expand Up @@ -198,7 +192,7 @@ export const mergeAssociatedToCs = async (metadata: Metadata) => {
const mergedMetadataEntries = [umbrellaMetadata, ...associatedMetadataEntries].map((metadataEntry) => {
const mergedMetadataEntry = traverseAndMerge(
metadataEntry,
umbrellaMetadata.associated_products || [],
umbrellaMetadata,
umbrellaToCs,
tocInsertions,
tocOrderInsertions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ const getAggregationPipeline = (matchCondition: any) => {
repo: 0,
},
},
{
$sort: {
prodDeployable: -1,
},
},
];
};

Expand Down
4 changes: 2 additions & 2 deletions modules/persistence/tests/metadata/ToC.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ describe('ToC module', () => {
expect(
traverseAndMerge(
umbrellaMetadata as unknown as Metadata,
umbrellaMetadata.associated_products || [],
umbrellaMetadata,
umbrellaToCs,
tocInsertions,
tocOrderInsertions
Expand All @@ -135,7 +135,7 @@ describe('ToC module', () => {
expect(
traverseAndMerge(
metadata[0] as unknown as Metadata,
umbrellaMetadata.associated_products || [],
umbrellaMetadata,
umbrellaToCs,
tocInsertions,
tocOrderInsertions
Expand Down
1 change: 1 addition & 0 deletions modules/persistence/tests/setupAfterEnv.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
beforeAll(() => {
// Disable console.time from crowding test output
console.time = jest.fn();
global.structuredClone = (val) => JSON.parse(JSON.stringify(val));
});

0 comments on commit bb41a5f

Please sign in to comment.