Skip to content

Commit

Permalink
fix some formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
CollinBeczak committed Jan 9, 2024
1 parent 678ee4e commit aac8fbd
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 35 deletions.
2 changes: 1 addition & 1 deletion src/components/HOCs/WithUserMetrics/WithUserMetrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export const WithUserMetrics = function(WrappedComponent, userProp) {
setTasksReviewerMonthsPast={this.setTasksReviewerMonthsPast}
setTasksReviewerDateRange={this.setTasksReviewerDateRange}
loading={this.state.loading}
{..._omit(this.props, ['fetchLeaderboardForUser'])} />)
{..._omit(this.props, ['updateLeaderboardMetrics', 'fetchLeaderboardForUser'])} />)
}
}
}
Expand Down
72 changes: 38 additions & 34 deletions src/services/Leaderboard/Leaderboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,35 +39,36 @@ export const fetchLeaderboard = (numberMonths=null, onlyEnabled=true,
forProjects=null, forChallenges=null,
forUsers=null, forCountries=null,
limit=10, startDate=null, endDate=null) => {
const params = {
limit,
onlyEnabled
}
return async function (dispatch) {
initializeLeaderboardParams(params, numberMonths, forProjects, forChallenges,
forUsers, forCountries, startDate, endDate)

const cachedLeaderboard = leaderboardCache.get({}, params, GLOBAL_LEADERBOARD_CACHE);

if (cachedLeaderboard) {
return cachedLeaderboard;
}

try {
const results = await new Endpoint(api.users.leaderboard, { params }).execute()

if (results) {
leaderboardCache.set({}, params, results, GLOBAL_LEADERBOARD_CACHE)
}

return results
} catch (error) {
console.error('Error fetching leaderboard:', error)
dispatch(addError(AppErrors.leaderboard.fetchFailure))
return []
}
}
}
const params = {
limit,
onlyEnabled
}

return async function (dispatch) {
initializeLeaderboardParams(params, numberMonths, forProjects, forChallenges,
forUsers, forCountries, startDate, endDate)

const cachedLeaderboard = leaderboardCache.get({}, params, GLOBAL_LEADERBOARD_CACHE);

if (cachedLeaderboard) {
return cachedLeaderboard;
}

try {
const results = await new Endpoint(api.users.leaderboard, { params }).execute()

if (results) {
leaderboardCache.set({}, params, results, GLOBAL_LEADERBOARD_CACHE)
}

return results
} catch (error) {
console.error('Error fetching leaderboard:', error)
dispatch(addError(AppErrors.leaderboard.fetchFailure))
return []
}
}
}

/**
* Retrieve leaderboard data for a user from the server for the given date range and
Expand All @@ -78,12 +79,13 @@ export const fetchLeaderboardForUser = (userId, bracket=0, numberMonths=1,
onlyEnabled=true, forProjects=null, forChallenges=null,
forUsers, forCountries=null, startDate=null,
endDate=null) => {
return async function (dispatch) {
const params = {
bracket,
onlyEnabled
}

return async function (dispatch) {

const variables = {
id: userId
}
Expand Down Expand Up @@ -122,12 +124,14 @@ export const fetchReviewerLeaderboard = (numberMonths=null, onlyEnabled=true,
forProjects=null, forChallenges=null,
forUsers=null, forCountries=null,
limit=10, startDate=null, endDate=null) => {

const params = {
limit,
onlyEnabled
}

return async function (dispatch) {
try {
const params = {
limit,
onlyEnabled
}

initializeLeaderboardParams(params, numberMonths, forProjects, forChallenges,
forUsers, forCountries, startDate, endDate)
Expand Down

0 comments on commit aac8fbd

Please sign in to comment.