Skip to content

Commit

Permalink
Merge pull request #2868 from uselagoon/feature/facts-limit
Browse files Browse the repository at this point in the history
  • Loading branch information
tobybellwood authored Oct 20, 2021
2 parents 93bae42 + 1a1530a commit 4799ad0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 3 additions & 2 deletions services/api/src/resources/fact/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { logger } from '../../loggers/logger';

export const getFactsByEnvironmentId: ResolverFn = async (
{ id: environmentId, environmentAuthz },
{ keyFacts },
{ keyFacts, limit },
{ sqlClientPool, hasPermission }
) => {
const environment = await environmentHelpers(
Expand All @@ -25,7 +25,8 @@ export const getFactsByEnvironmentId: ResolverFn = async (
sqlClientPool,
Sql.selectFactsByEnvironmentId({
environmentId,
keyFacts
keyFacts,
limit
})
);

Expand Down
6 changes: 5 additions & 1 deletion services/api/src/resources/fact/sql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const Sql = {
.where('f.id', fid)
.orderBy('f.id', 'asc')
.toString(),
selectFactsByEnvironmentId: ({ environmentId, keyFacts }) => {
selectFactsByEnvironmentId: ({ environmentId, keyFacts, limit }) => {
let q = knex('environment_fact as f')
.distinct(standardFactReturn)
.leftJoin('environment_fact_reference as r', 'r.fid', '=', 'f.id')
Expand All @@ -31,6 +31,10 @@ export const Sql = {
q.where('f.keyFact', keyFacts);
}

if (limit) {
q.limit(limit);
}

return q.orderBy('f.id', 'asc').toString()
},
insertFact: ({ environment, name, value, source, description, type, category, keyFact }) =>
Expand Down
2 changes: 1 addition & 1 deletion services/api/src/typeDefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ const typeDefs = gql`
advancedTasks: [AdvancedTaskDefinition]
services: [EnvironmentService]
problems(severity: [ProblemSeverityRating], source: [String]): [Problem]
facts(keyFacts: Boolean): [Fact]
facts(keyFacts: Boolean, limit: Int): [Fact]
openshift: Openshift
openshiftProjectPattern: String
kubernetes: Kubernetes
Expand Down

0 comments on commit 4799ad0

Please sign in to comment.