Skip to content

Commit

Permalink
merge retry client
Browse files Browse the repository at this point in the history
  • Loading branch information
fcaps committed Nov 24, 2023
1 parent 19727cb commit bd83078
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 25 deletions.
4 changes: 2 additions & 2 deletions lib/clan/ClanRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class ClanRepository {
}

async fetchAll() {
const response = await this.javaApiClient.get('/data/clan?sort=createTime&include=leader&fields[clan]=name,tag,description,leader,memberships,createTime&fields[player]=login&page[number]=1&page[size]=3000')
const response = await this.javaApiClient.get('/data/clan?include=leader&fields[clan]=name,tag,description,leader,memberships,createTime&fields[player]=login&page[number]=1&page[size]=3000')

if (response.status !== 200) {
throw new Error('ClanRepository::fetchAll failed with response status "' + response.status + '"')
Expand Down Expand Up @@ -32,7 +32,7 @@ class ClanRepository {

const clans = responseData.data.map((item, index) => ({
id: parseInt(item.id),
leaderName: responseData.included[index].attributes.login,
leaderName: responseData.included[index]?.attributes.login || '-',
name: item.attributes.name,
tag: item.attributes.tag,
createTime: item.attributes.createTime,
Expand Down
14 changes: 0 additions & 14 deletions lib/clan/ClanServiceFactory.js

This file was deleted.

15 changes: 8 additions & 7 deletions routes/middleware.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
const WordpressServiceFactory = require("../lib/WordpressServiceFactory")
const ClanServiceFactory = require("../lib/clan/ClanServiceFactory")
const JavaApiClientFactory = require("../lib/JavaApiClient");
const appConfig = require("../config/app");
const LeaderboardService = require("../lib/LeaderboardService");
const cacheService = require("../lib/CacheService");
const LeaderboardRepository = require("../lib/LeaderboardRepository");
const JavaApiClientFactory = require("../lib/JavaApiClient")
const appConfig = require("../config/app")
const LeaderboardService = require("../lib/LeaderboardService")
const cacheService = require("../lib/CacheService")
const LeaderboardRepository = require("../lib/LeaderboardRepository")
const ClanService = require("../lib/clan/ClanService")
const ClanRepository = require("../lib/clan/ClanRepository")
const wordpressService = WordpressServiceFactory(appConfig.wordpressUrl)

exports.initLocals = function(req, res, next) {
Expand Down Expand Up @@ -52,7 +53,7 @@ exports.injectServices = function(req, res, next) {
if (req.isAuthenticated()) {
req.services.javaApiClient = JavaApiClientFactory(appConfig.apiUrl, req.user)
req.services.leaderboardService = new LeaderboardService(cacheService, new LeaderboardRepository(req.services.javaApiClient))
req.services.clanService = ClanServiceFactory(appConfig.apiUrl, req.user.data.attributes.token)
req.services.clanService = new ClanService(cacheService, new ClanRepository(req.services.javaApiClient))
}

next()
Expand Down
7 changes: 5 additions & 2 deletions templates/views/clans/clan.pug
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@ block content
td #{clan.tag}
tr
td LEADER
td #{clan.leader.name} 👑
if clan.leader
td #{clan.leader.name} 👑
else
td -
tr
td FOUNDER
if clan.founder
td #{clan.founder.name}
else
td GONE
td -
tr
td JOIN
if clan.requiresInvitation
Expand Down

0 comments on commit bd83078

Please sign in to comment.