Skip to content

Commit

Permalink
Fix: Corrected search ocurrence number in team member effort table pa…
Browse files Browse the repository at this point in the history
…gination
  • Loading branch information
j-fborges committed Oct 3, 2023
1 parent 266a0cf commit 7dc5e34
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 7 deletions.
6 changes: 6 additions & 0 deletions app/graphql/types/demand_efforts_list_type.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Types
class DemandEffortsListType < BaseObject
field :demand_efforts, [Types::DemandEffortType], null: true
field :demand_efforts_count, Int, null: true
end
end
11 changes: 11 additions & 0 deletions app/graphql/types/teams/team_member_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ class TeamMemberType < Types::BaseObject
field :start_date, GraphQL::Types::ISO8601Date, null: true
field :teams, [Types::Teams::TeamType], null: true
field :user, Types::UserType, null: true
field :demand_efforts_list, Types::DemandEffortsListType, null: true do
argument :from_date, GraphQL::Types::ISO8601Date, required: false
argument :until_date, GraphQL::Types::ISO8601Date, required: false
argument :page_number, Integer, required: false
end

field :demands, [Types::DemandType] do
argument :limit, Int, required: false
Expand Down Expand Up @@ -79,6 +84,12 @@ def demands(status: 'ALL', type: 'ALL', limit: nil)
demands.limit(limit)
end

def demand_efforts_list(from_date: nil, until_date: nil, page_number: nil)
efforts = object.demand_efforts.to_dates(from_date, until_date).order(start_time_to_computation: :desc)
efforts_paginated = efforts.page(page_number).per(10)
{ 'demand_efforts_count' => efforts.count, 'demand_efforts' => efforts_paginated }
end

def projects_list(order_field:, sort_direction: 'ASC', per_page: 10, page_number: 1)
projects = if sort_direction == 'DESC'
object.projects.order("#{order_field} DESC")
Expand Down
4 changes: 2 additions & 2 deletions app/spa/src/components/TeamMemberDashboardTables.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ const TeamMemberDashboardTables = ({
t("dashboard.latestEfforts.effortValue"),
]

const latestEffortsRows = teamMember?.demandEfforts?.map((effort) => [
const latestEffortsRows = teamMember?.demandEffortsList?.demandEfforts?.map((effort) => [
<Link
component={RouterLink}
to={`/companies/taller/teams/${effort.team?.id}`}
Expand Down Expand Up @@ -234,7 +234,7 @@ const TeamMemberDashboardTables = ({
headerCells={latestEffortsHeader}
rows={latestEffortsRows || []}
pagination={{
count: (teamMember?.demandEfforts?.length || 0),
count: (teamMember?.demandEffortsList?.demandEffortsCount|| 0),
rowsPerPage: (10),
page: effortsFilters.pageNumber - 1,
onPageChange: (_, newPage: number) =>
Expand Down
5 changes: 2 additions & 3 deletions app/spa/src/components/ui/DateLocale.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ import { formatDate } from "../../lib/date"
type DateLocaleProps = {
date: string
time?: boolean
isPtBr?: boolean
}

const DateLocale = ({ date, time }: DateLocaleProps) => {
const { i18n } = useTranslation()
const isPtBr = i18n.language === "pt"
const DateLocale = ({ date, time, isPtBr = true}: DateLocaleProps) => {
const dateFormat = isPtBr ? "dd/MM/yyyy" : "MM/dd/yyyy"
const format = time ? `${dateFormat} HH:mm` : dateFormat

Expand Down
4 changes: 4 additions & 0 deletions app/spa/src/modules/teamMember/teamMember.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,8 @@ export type TeamMember = {
yAxisProjectsNames: string[]
}
demandEfforts?: DemandEffort[]
demandEffortsList?: {
demandEfforts?: DemandEffort[]
demandEffortsCount?: number
}
}
28 changes: 28 additions & 0 deletions app/spa/src/pages/TeamMembers/TeamMemberDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,34 @@ const TEAM_MEMBER_QUERY = gql`
automaticUpdate
membershipEffortPercentage
}
demandEffortsList(fromDate: $fromDate, untilDate: $untilDate, pageNumber: $pageNumber) {
demandEfforts{
id
effortValue
effortMoney
startTimeToComputation
finishTimeToComputation
stagePercentage
pairingPercentage
managementPercentage
totalBlocked
mainEffortInTransition
stage
who
team {
id
name
}
createdAt
updatedAt
demandId
demandExternalId
memberRole
automaticUpdate
membershipEffortPercentage
}
demandEffortsCount
}
}
}
`
Expand Down
10 changes: 8 additions & 2 deletions spec/graphql/types/query_type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1884,9 +1884,12 @@
xAxis
yAxis
}
demandEfforts(fromDate: "#{25.days.ago.iso8601}", untilDate: "#{15.days.ago.iso8601}"){
demandEfforts(fromDate: "#{25.days.ago.iso8601}", untilDate: "#{15.days.ago.iso8601}", pageNumber: 1){
finishTimeToComputation
}
demandEffortsList(fromDate: "#{25.days.ago.iso8601}", untilDate: "#{15.days.ago.iso8601}", pageNumber: 1){
demandEffortsCount
}
projectHoursData {
xAxis
yAxisProjectsNames
Expand Down Expand Up @@ -2043,7 +2046,10 @@
'memberThroughputData' => [0, 0, 0, 2],
'demandEfforts' => [{
'finishTimeToComputation' => '2022-05-03T10:00:00-03:00'
}]
}],
'demandEffortsList' => {
'demandEffortsCount' => 1
}
})
end
end
Expand Down

0 comments on commit 7dc5e34

Please sign in to comment.