Skip to content

Commit debc4e3

Browse files
authored
feat: opportunity preview details (#3327)
1 parent da5e98b commit debc4e3

3 files changed

Lines changed: 283 additions & 40 deletions

File tree

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
const SHOWCASE_COMPANIES = [
2+
{
3+
name: 'Microsoft',
4+
favicon: 'https://www.microsoft.com/',
5+
},
6+
{
7+
name: 'Google',
8+
favicon: 'https://www.google.com/',
9+
},
10+
{
11+
name: 'Apple',
12+
favicon: 'https://www.apple.com/',
13+
},
14+
{
15+
name: 'IBM',
16+
favicon: 'https://www.ibm.com/',
17+
},
18+
{
19+
name: 'Oracle',
20+
favicon: 'https://www.oracle.com/',
21+
},
22+
{
23+
name: 'Salesforce',
24+
favicon: 'https://www.salesforce.com/',
25+
},
26+
{
27+
name: 'GitHub',
28+
favicon: 'https://github.com/',
29+
},
30+
{
31+
name: 'Atlassian',
32+
favicon: 'https://www.atlassian.com/',
33+
},
34+
{
35+
name: 'Cisco',
36+
favicon: 'https://www.cisco.com/',
37+
},
38+
{
39+
name: 'Intel',
40+
favicon: 'https://www.intel.com/',
41+
},
42+
{
43+
name: 'AMD',
44+
favicon: 'https://www.amd.com/',
45+
},
46+
{
47+
name: 'SAP',
48+
favicon: 'https://www.sap.com/',
49+
},
50+
{
51+
name: 'Vercel',
52+
favicon: 'https://vercel.com/',
53+
},
54+
{
55+
name: 'Docker',
56+
favicon: 'https://www.docker.com/',
57+
},
58+
{
59+
name: 'Spotify',
60+
favicon: 'https://www.spotify.com/',
61+
},
62+
{
63+
name: 'Netflix',
64+
favicon: 'https://www.netflix.com/',
65+
},
66+
{
67+
name: 'Coinbase',
68+
favicon: 'https://www.coinbase.com/',
69+
},
70+
{
71+
name: 'Kraken',
72+
favicon: 'https://www.kraken.com/',
73+
},
74+
{
75+
name: 'Twilio',
76+
favicon: 'https://www.twilio.com/',
77+
},
78+
{
79+
name: 'Shopify',
80+
favicon: 'https://www.shopify.com/',
81+
},
82+
{
83+
name: 'Wix',
84+
favicon: 'https://www.wix.com/',
85+
},
86+
{
87+
name: 'Red Hat',
88+
favicon: 'https://www.redhat.com/',
89+
},
90+
{
91+
name: 'Tesla',
92+
favicon: 'https://www.tesla.com/',
93+
},
94+
{
95+
name: 'Square (Block)',
96+
favicon: 'https://squareup.com/',
97+
},
98+
{
99+
name: 'Ericsson',
100+
favicon: 'https://www.ericsson.com/',
101+
},
102+
{
103+
name: 'Databricks',
104+
favicon: 'https://www.databricks.com/',
105+
},
106+
{
107+
name: 'Snowflake',
108+
favicon: 'https://www.snowflake.com/',
109+
},
110+
{
111+
name: 'Sentry',
112+
favicon: 'https://sentry.io/',
113+
},
114+
{
115+
name: 'BrowserStack',
116+
favicon: 'https://www.browserstack.com/',
117+
},
118+
{
119+
name: 'VMware',
120+
favicon: 'https://www.vmware.com/',
121+
},
122+
{
123+
name: 'Autodesk',
124+
favicon: 'https://www.autodesk.com/',
125+
},
126+
{
127+
name: 'Huawei',
128+
favicon: 'https://www.huawei.com/',
129+
},
130+
{
131+
name: 'PwC',
132+
favicon: 'https://www.pwc.com/',
133+
},
134+
{
135+
name: 'CERN',
136+
favicon: 'https://home.cern/',
137+
},
138+
{
139+
name: 'NASA',
140+
favicon: 'https://www.nasa.gov/',
141+
},
142+
{
143+
name: 'Ubisoft',
144+
favicon: 'https://www.ubisoft.com/',
145+
},
146+
{
147+
name: 'Cognizant',
148+
favicon: 'https://www.cognizant.com/',
149+
},
150+
{
151+
name: 'Accenture',
152+
favicon: 'https://www.accenture.com/',
153+
},
154+
{
155+
name: 'TCS',
156+
favicon: 'https://www.tcs.com/',
157+
},
158+
{
159+
name: 'Wipro',
160+
favicon: 'https://www.wipro.com/',
161+
},
162+
{
163+
name: 'Infosys',
164+
favicon: 'https://www.infosys.com/',
165+
},
166+
{
167+
name: 'Capgemini',
168+
favicon: 'https://www.capgemini.com/',
169+
},
170+
{
171+
name: 'NTT DATA',
172+
favicon: 'https://www.nttdata.com/',
173+
},
174+
{
175+
name: 'Broadcom',
176+
favicon: 'https://www.broadcom.com/',
177+
},
178+
{
179+
name: 'Siemens',
180+
favicon: 'https://www.siemens.com/',
181+
},
182+
{
183+
name: 'Deutsche Bank',
184+
favicon: 'https://www.db.com/',
185+
},
186+
{
187+
name: 'JPMorgan Chase & Co',
188+
favicon: 'https://www.jpmorganchase.com/',
189+
},
190+
{
191+
name: 'Capital One',
192+
favicon: 'https://www.capitalone.com/',
193+
},
194+
{
195+
name: 'Mastercard',
196+
favicon: 'https://www.mastercard.com/',
197+
},
198+
{
199+
name: 'Vodafone Group',
200+
favicon: 'https://www.vodafone.com/',
201+
},
202+
];
203+
204+
export const getShowcaseCompanies = () => {
205+
const shuffled = [...SHOWCASE_COMPANIES].sort(() => Math.random() - 0.5);
206+
return shuffled.slice(0, 6);
207+
};

src/graphorm/index.ts

Lines changed: 40 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ import {
3737
domainOnly,
3838
getSmartTitle,
3939
getTranslationRecord,
40-
getUserTopReadingTags,
4140
transformDate,
4241
} from '../common';
4342
import { GQLComment } from '../schema/comments';
@@ -1841,23 +1840,35 @@ const obj = new GraphORM({
18411840
},
18421841
},
18431842
topTags: {
1844-
select: () => 'NULL',
1845-
transform: async (_, ctx, parent) => {
1846-
const user = parent as User;
1847-
if (!user.id) {
1848-
return null;
1849-
}
1850-
try {
1851-
const tags = await getUserTopReadingTags(ctx.con, {
1852-
userId: user.id,
1853-
limit: 5,
1854-
readLimit: 100,
1855-
});
1856-
return tags && tags.length > 0 ? tags.map((t) => t.tag) : null;
1857-
} catch (error) {
1858-
return null;
1859-
}
1860-
},
1843+
select: (_, alias) => `
1844+
COALESCE(
1845+
(
1846+
SELECT ARRAY(
1847+
SELECT tag
1848+
FROM (
1849+
SELECT
1850+
pk.keyword AS tag,
1851+
COUNT(*) AS count
1852+
FROM (
1853+
SELECT v."postId"
1854+
FROM "view" v
1855+
WHERE v."userId" = ${alias}.id
1856+
AND v.hidden = false
1857+
ORDER BY v.timestamp DESC
1858+
LIMIT 100
1859+
) recent_reads
1860+
JOIN post_keyword pk ON recent_reads."postId" = pk."postId"
1861+
WHERE pk.status = 'allow'
1862+
AND pk.keyword != 'general-programming'
1863+
GROUP BY pk.keyword
1864+
ORDER BY COUNT(*) DESC
1865+
LIMIT 5
1866+
) top_tags
1867+
)
1868+
),
1869+
ARRAY[]::text[]
1870+
)
1871+
`,
18611872
},
18621873
recentlyRead: {
18631874
select: (_, alias, qb) =>
@@ -1881,17 +1892,17 @@ const obj = new GraphORM({
18811892
},
18821893
activeSquads: {
18831894
select: (_, alias) => `
1884-
ARRAY(
1885-
SELECT sm."sourceId"
1886-
FROM source_member sm
1887-
INNER JOIN source s ON s.id = sm."sourceId"
1888-
WHERE sm."userId" = ${alias}.id
1889-
AND s.type = '${SourceType.Squad}'
1890-
AND s.active = true
1891-
ORDER BY sm."createdAt" DESC
1892-
LIMIT 5
1893-
)
1894-
`,
1895+
ARRAY(
1896+
SELECT sm."sourceId"
1897+
FROM source_member sm
1898+
INNER JOIN source s ON s.id = sm."sourceId"
1899+
WHERE sm."userId" = ${alias}.id
1900+
AND s.type = '${SourceType.Squad}'
1901+
AND s.active = true
1902+
ORDER BY sm."createdAt" DESC
1903+
LIMIT 5
1904+
)
1905+
`,
18951906
},
18961907
},
18971908
},

0 commit comments

Comments
 (0)