-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Restructure APG Support Tables #1053
Changes from 5 commits
4360be4
b437907
2150fbe
e4dea58
36bc827
f0b4361
d6c39bf
663a738
f92bcac
c6b12c1
9b83341
5cb2368
fd6dcb1
dc10f03
a4b077e
540c712
e69468a
dff75f3
c2787fa
20c72f6
2f1831f
f12437f
fe617b5
9161715
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,10 +30,10 @@ app.set('views', path.resolve(handlebarsPath, 'views')); | |
// stale data for however long it takes for the query to complete. | ||
const millisecondsUntilStale = 5000; | ||
|
||
const queryReports = async () => { | ||
const queryReports = async testPlanDirectory => { | ||
const { data, errors } = await apolloServer.executeOperation({ | ||
query: gql` | ||
query { | ||
query TestPlanQuery($testPlanDirectory: ID!) { | ||
ats { | ||
id | ||
name | ||
|
@@ -42,6 +42,30 @@ const queryReports = async () => { | |
name | ||
} | ||
} | ||
testPlan(id: $testPlanDirectory) { | ||
testPlanVersions { | ||
id | ||
title | ||
phase | ||
testPlanReports(isFinal: true) { | ||
id | ||
metrics | ||
at { | ||
id | ||
name | ||
} | ||
browser { | ||
id | ||
name | ||
} | ||
latestAtVersionReleasedAt { | ||
id | ||
name | ||
releasedAt | ||
} | ||
} | ||
} | ||
} | ||
testPlanReports( | ||
testPlanVersionPhases: [CANDIDATE, RECOMMENDED] | ||
isFinal: true | ||
|
@@ -69,16 +93,11 @@ const queryReports = async () => { | |
testPlan { | ||
id | ||
} | ||
tests { | ||
ats { | ||
id | ||
name | ||
} | ||
} | ||
} | ||
} | ||
} | ||
` | ||
`, | ||
variables: { testPlanDirectory } | ||
}); | ||
|
||
if (errors) { | ||
|
@@ -97,6 +116,7 @@ const queryReports = async () => { | |
// As of now, a full query for the complete list of reports is needed to build | ||
// the embed for a single pattern. This caching allows that query to be reused | ||
// between pattern embeds. | ||
|
||
const queryReportsCached = staleWhileRevalidate(queryReports, { | ||
millisecondsUntilStale | ||
}); | ||
|
@@ -196,14 +216,16 @@ const getLatestReportsForPattern = ({ allTestPlanReports, pattern }) => { | |
allAtVersionsByAt, | ||
testPlanVersionIds, | ||
phase, | ||
reportsByAt | ||
reportsByAt, | ||
latestReports | ||
}; | ||
}; | ||
|
||
const priorities = ['MUST', 'SHOULD']; | ||
const renderEmbed = ({ | ||
ats, | ||
allTestPlanReports, | ||
queryTitle, | ||
priorities, | ||
pattern, | ||
protocol, | ||
host | ||
|
@@ -214,8 +236,9 @@ const renderEmbed = ({ | |
allAtVersionsByAt, | ||
testPlanVersionIds, | ||
phase, | ||
reportsByAt | ||
} = getLatestReportsForPattern({ pattern, allTestPlanReports }); | ||
reportsByAt, | ||
latestReports | ||
} = getLatestReportsForPattern({ allTestPlanReports, pattern }); | ||
const allAtBrowserCombinations = Object.fromEntries( | ||
ats.map(at => { | ||
return [ | ||
|
@@ -233,10 +256,12 @@ const renderEmbed = ({ | |
allAtBrowserCombinations, | ||
title: queryTitle || title || 'Pattern Not Found', | ||
pattern, | ||
priorities, | ||
phase, | ||
allBrowsers, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a lot of dead code still in this file, like this variable is not used anywhere for example. Would it be possible to simplify this file a bit? It's currently getting pretty intimidating. Acknowledging of course that I contributed more than anyone to the current situation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So yes the variable appears 7 times in this file, but all of those uses are only related to setting the variable, not using it. Then if you look at the helpers file and main.hbs you'll see that this variable is passed around a bit but never used. That's what I mean when I say it's dead code. The larger issue, beyond this one variable, is that a lot of the code in this file is passed around and set but never actually utilized, and I think it's definitely worth the effort to overhaul the whole file and remove all the dead code. |
||
allAtVersionsByAt, | ||
reportsByAt, | ||
latestReports, | ||
completeReportLink: `${protocol}${host}/report/${testPlanVersionIds.join( | ||
',' | ||
)}`, | ||
|
@@ -262,12 +287,14 @@ app.get('/reports/:pattern', async (req, res) => { | |
const protocol = /dev|vagrant/.test(process.env.ENVIRONMENT) | ||
? 'http://' | ||
: 'https://'; | ||
const { allTestPlanReports, reportsHashed, ats } = | ||
await queryReportsCached(); | ||
const { allTestPlanReports, reportsHashed, ats } = await queryReportsCached( | ||
pattern | ||
); | ||
const embedRendered = await renderEmbedCached({ | ||
ats, | ||
allTestPlanReports, | ||
reportsHashed, | ||
priorities, | ||
queryTitle, | ||
pattern, | ||
protocol, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to remove this part of the query?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so.
testPlanReports
is being used in the code.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I said in another comment, you're right that it's being used. My point is more that it's only being used by dead code and the whole network of dead code present in this file can be removed.