Skip to content

Commit

Permalink
feat: more filters for deploymentsByFilter
Browse files Browse the repository at this point in the history
  • Loading branch information
shreddedbacon committed Feb 11, 2025
1 parent b17d3d5 commit 4c153f2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
17 changes: 8 additions & 9 deletions services/api/src/resources/deployment/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export const getDeploymentsByFilter: ResolverFn = async (
{ sqlClientPool, hasPermission, models, keycloakGrant, keycloakUsersGroups, adminScopes }
) => {

const { openshifts, deploymentStatus = ["NEW", "PENDING", "RUNNING", "QUEUED"], month, includeDeleted } = input;
const { openshifts, deploymentStatus = ["NEW", "PENDING", "RUNNING", "QUEUED"], startDate, endDate, includeDeleted } = input;

/*
use the same mechanism for viewing all projects
Expand Down Expand Up @@ -181,14 +181,13 @@ export const getDeploymentsByFilter: ResolverFn = async (
queryBuilder = queryBuilder.whereIn('environment.project', userProjectIds);
}

// collect builds for a specific year/month
if (month) {
queryBuilder = queryBuilder.andWhere(
knex.raw(`YEAR(deployment.created) = YEAR(STR_TO_DATE(?, '%Y-%m'))`, month),
)
.andWhere(
knex.raw(`MONTH(deployment.created) = MONTH(STR_TO_DATE(?, '%Y-%m'))`, month),
);
// collect builds for a specific date range
if (startDate) {
queryBuilder = queryBuilder.where('deployment.created', '>=', input.startDate);
}

if (endDate) {
queryBuilder = queryBuilder.where('deployment.created', '<=', input.endDate);
}

if(openshifts) {
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 @@ -1350,7 +1350,7 @@ const typeDefs = gql`
deploymentByRemoteId(id: String): Deployment
deploymentByName(input: DeploymentByNameInput): Deployment
deploymentsByBulkId(bulkId: String): [Deployment]
deploymentsByFilter(openshifts: [Int], deploymentStatus: [DeploymentStatusType], month: Date, includeDeleted: Boolean): [Deployment]
deploymentsByFilter(openshifts: [Int], deploymentStatus: [DeploymentStatusType], startDate: Date, endDate: Date, includeDeleted: Boolean): [Deployment]
taskByTaskName(taskName: String): Task
taskByRemoteId(id: String): Task
taskById(id: Int): Task
Expand Down

0 comments on commit 4c153f2

Please sign in to comment.