Skip to content

Commit

Permalink
remove lead stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Nov 11, 2020
1 parent 2eeebe9 commit 19c1a0b
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 237 deletions.
1 change: 0 additions & 1 deletion Procfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ dynoskimmer: node lib/server/processes/dynoCleanup.js
orgdeleter: node lib/server/processes/orgDeleter.js
deployidcleanup: node lib/server/processes/deployIdCleanup.js
herokucdscheck: node lib/server/processes/herokuExpirationChecker.js
leadqueue: node lib/server/processes/trialLeadCreate.js
pooldrain: node lib/server/processes/poolDrainSubscriber.js
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"@salesforce-ux/design-system": "^2.9.3",
"@salesforce/analytics": "0.17.0",
"@salesforce/kit": "^1.1.1",
"axios": "^0.19.0",
"cors": "^2.8.5",
"deepmerge": "^4.2.2",
"express": "^4.16.4",
Expand Down
43 changes: 0 additions & 43 deletions src/server/__tests__/helpers/sampleLead.ts

This file was deleted.

76 changes: 0 additions & 76 deletions src/server/__tests__/integrationTests/trialsignup.test.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/server/__tests__/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"moduleResolution": "node",
"module": "none",
"removeComments": true,
"types": ["node", "jest", "express", "ioredis", "fs-extra", "moment", "axios", "request-promise-native", "universal-analytics"]
"types": ["node", "jest", "express", "ioredis", "fs-extra", "moment", "request-promise-native", "universal-analytics"]
},

"compileOnSave": true
Expand Down
48 changes: 0 additions & 48 deletions src/server/lib/leadSupport.ts

This file was deleted.

3 changes: 1 addition & 2 deletions src/server/lib/processWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ const processWrapper = {

// google analytics
UA_ID: process.env.UA_ID,

sfdcLeadCaptureServlet: process.env.sfdcLeadCaptureServlet
LEAD_QUEUE: process.env.LEAD_QUEUE
};

export { processWrapper };
51 changes: 24 additions & 27 deletions src/server/lib/redisNormal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ const deployRequestExchange = 'deploys';
export const poolDeployExchange = 'poolDeploys';
const orgDeleteExchange = 'orgDeletes';
const herokuCDSExchange = 'herokuCDSs';
const leadQueue = 'leads';
const failedLeadQueue = 'failedLeads';
const leadQueue = processWrapper.LEAD_QUEUE || 'leads';

const days31asSeconds = 31 * 24 * 60 * 60;

Expand All @@ -46,19 +45,26 @@ const putHerokuCDS = async (cds: CDS): Promise<void> => {
};

const getHerokuCDSs = async (): Promise<CDS[]> => {
const CDSs: CDS[] = (await redis.lrange(herokuCDSExchange, 0, -1)).map((queueItem) => JSON.parse(queueItem));
const CDSs: CDS[] = (await redis.lrange(herokuCDSExchange, 0, -1)).map((queueItem) =>
JSON.parse(queueItem)
);
return CDSs;
};

const getAppNamesFromHerokuCDSs = async (salesforceUsername: string, expecting = true): Promise<string[]> => {
const getAppNamesFromHerokuCDSs = async (
salesforceUsername: string,
expecting = true
): Promise<string[]> => {
// get all the CDSs
const herokuCDSs = await getHerokuCDSs();

if (herokuCDSs.length === 0) {
return [];
}
// find the matching username
const matchedCDSIndex = herokuCDSs.findIndex((cds) => cds.mainUser.username === salesforceUsername);
const matchedCDSIndex = herokuCDSs.findIndex(
(cds) => cds.mainUser.username === salesforceUsername
);

if (matchedCDSIndex < 0) {
if (expecting) {
Expand All @@ -69,7 +75,9 @@ const getAppNamesFromHerokuCDSs = async (salesforceUsername: string, expecting =
return [];
}

logger.debug(`found matching cds ${salesforceUsername} === ${herokuCDSs[matchedCDSIndex].mainUser.username}`);
logger.debug(
`found matching cds ${salesforceUsername} === ${herokuCDSs[matchedCDSIndex].mainUser.username}`
);

const matched = herokuCDSs.splice(matchedCDSIndex, 1);

Expand Down Expand Up @@ -173,7 +181,8 @@ const cdsRetrieve = async (deployId: string) => {
errors: [
{
command: 'retrieval',
error: 'Results not found for your deployId. It may have been deleted or may have expired',
error:
'Results not found for your deployId. It may have been deleted or may have expired',
raw: ''
}
]
Expand Down Expand Up @@ -220,9 +229,11 @@ const putPooledOrg = async (depReq: DeployRequest, poolMessage: CDS): Promise<vo
await redis.rpush(key, JSON.stringify(poolMessage));
};

const getAllPooledOrgs = async (poolname: string): Promise<CDS[]> => (await redis.lrange(poolname, 0, -1)).map((msg) => JSON.parse(msg));
const getAllPooledOrgs = async (poolname: string): Promise<CDS[]> =>
(await redis.lrange(poolname, 0, -1)).map((msg) => JSON.parse(msg));

const getAllPooledOrgIDs = async (poolname: string): Promise<string[]> => (await getAllPooledOrgs(poolname)).map((cds) => cds.orgId);
const getAllPooledOrgIDs = async (poolname: string): Promise<string[]> =>
(await getAllPooledOrgs(poolname)).map((cds) => cds.orgId);

const getPoolDeployRequestQueueSize = async () => redis.llen(poolDeployExchange);

Expand All @@ -231,28 +242,17 @@ const getPoolDeployRequestQueueSize = async () => redis.llen(poolDeployExchange)
*/
const getPoolDeployCountByRepo = async (pool: PoolConfig) => {
const poolRequests = await redis.lrange(poolDeployExchange, 0, -1);
return poolRequests.map((pr) => JSON.parse(pr)).filter((pr: DeployRequest) => equal(pr.repos, pool.repos)).length;
return poolRequests
.map((pr) => JSON.parse(pr))
.filter((pr: DeployRequest) => equal(pr.repos, pool.repos)).length;
};

const putLead = async (lead) => {
if (processWrapper.sfdcLeadCaptureServlet) {
if (processWrapper.LEAD_QUEUE) {
await redis.rpush(leadQueue, JSON.stringify(lead));
}
};

const putFailedLead = async (lead) => {
if (processWrapper.sfdcLeadCaptureServlet) {
await redis.rpush(failedLeadQueue, JSON.stringify(lead));
}
};

const getLead = async () => {
const lead = await redis.lpop(leadQueue);
return JSON.parse(lead);
};

const getLeadQueueSize = async () => redis.llen(leadQueue);

export {
redis,
deployRequestExchange,
Expand All @@ -279,9 +279,6 @@ export {
getAppNamesFromHerokuCDSs,
getHerokuCDSs,
putLead,
getLead,
getLeadQueueSize,
putFailedLead,
getAllPooledOrgs,
getAllPooledOrgIDs
};
22 changes: 0 additions & 22 deletions src/server/processes/trialLeadCreate.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/server/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"resolveJsonModule": true,

"removeComments": true,
"types": ["node", "jest", "express", "ioredis", "fs-extra", "moment", "axios", "request-promise-native", "universal-analytics"]
"types": ["node", "jest", "express", "ioredis", "fs-extra", "moment", "request-promise-native", "universal-analytics"]
}
// "compileOnSave": true,
// "include": ["./src/server/**"],
Expand Down
16 changes: 1 addition & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3477,13 +3477,6 @@ aws4@^1.8.0:
resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.11.0.tgz#d61f46d83b2519250e2784daf5b09479a8b41c59"
integrity sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA==

axios@^0.19.0:
version "0.19.2"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.19.2.tgz#3ea36c5d8818d0d5f8a8a97a6d36b86cdc00cb27"
integrity sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA==
dependencies:
follow-redirects "1.5.10"

babel-code-frame@^6.22.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b"
Expand Down Expand Up @@ -5409,7 +5402,7 @@ debug@2.6.9, debug@^2.2.0, debug@^2.3.3, debug@^2.6.0, debug@^2.6.8, debug@^2.6.
dependencies:
ms "2.0.0"

debug@3.1.0, debug@=3.1.0:
debug@3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261"
integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==
Expand Down Expand Up @@ -7034,13 +7027,6 @@ flush-write-stream@^1.0.0:
inherits "^2.0.3"
readable-stream "^2.3.6"

follow-redirects@1.5.10:
version "1.5.10"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.5.10.tgz#7b7a9f9aea2fdff36786a94ff643ed07f4ff5e2a"
integrity sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==
dependencies:
debug "=3.1.0"

follow-redirects@^1.0.0:
version "1.12.1"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.12.1.tgz#de54a6205311b93d60398ebc01cf7015682312b6"
Expand Down

0 comments on commit 19c1a0b

Please sign in to comment.