Skip to content

Commit

Permalink
chore: disable link stats temporarily
Browse files Browse the repository at this point in the history
  • Loading branch information
gweiying committed Mar 21, 2024
1 parent 822d2db commit 7cf0e5d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
24 changes: 12 additions & 12 deletions src/server/modules/redirect/__tests__/RedirectController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,8 @@ describe('redirect API tests', () => {
.get<RedirectController>(DependencyIds.redirectController)
.redirect(req, res)

expect(updateStatisticsSpy).toBeCalledWith('aaa', userAgent)
expect(updateStatisticsSpy).toBeCalledTimes(1)
// expect(updateStatisticsSpy).toBeCalledWith('aaa', userAgent)
// expect(updateStatisticsSpy).toBeCalledTimes(1)
expect(res.statusCode).toBe(200)
expect(res._getRedirectUrl()).toBe('')
expect(
Expand Down Expand Up @@ -315,8 +315,8 @@ describe('redirect API tests', () => {
.get<RedirectController>(DependencyIds.redirectController)
.redirect(req, res)

expect(updateStatisticsSpy).toBeCalledWith('aaa', userAgent)
expect(updateStatisticsSpy).toBeCalledTimes(1)
// expect(updateStatisticsSpy).toBeCalledWith('aaa', userAgent)
// expect(updateStatisticsSpy).toBeCalledTimes(1)
expect(res.statusCode).toBe(302)
expect(res._getRedirectUrl()).toBe('aa')
expect(
Expand All @@ -341,8 +341,8 @@ describe('redirect API tests', () => {
.get<RedirectController>(DependencyIds.redirectController)
.redirect(req, res)

expect(updateStatisticsSpy).toBeCalledWith('aaa', userAgent)
expect(updateStatisticsSpy).toBeCalledTimes(1)
// expect(updateStatisticsSpy).toBeCalledWith('aaa', userAgent)
// expect(updateStatisticsSpy).toBeCalledTimes(1)
expect(res.statusCode).toBe(302)
expect(res.cookies.gaClientId).toBeTruthy()
expect(res._getRedirectUrl()).toBe('aa')
Expand All @@ -364,8 +364,8 @@ describe('redirect API tests', () => {
.get<RedirectController>(DependencyIds.redirectController)
.redirect(req, res)

expect(updateStatisticsSpy).toBeCalledWith('aaa', '')
expect(updateStatisticsSpy).toBeCalledTimes(1)
// expect(updateStatisticsSpy).toBeCalledWith('aaa', '')
// expect(updateStatisticsSpy).toBeCalledTimes(1)
expect(res.statusCode).toBe(302)
expect(res._getRedirectUrl()).toBe('aa')
})
Expand All @@ -380,8 +380,8 @@ describe('redirect API tests', () => {

expect(res.statusCode).toBe(302)
expect(res._getRedirectUrl()).toBe('aa')
expect(updateStatisticsSpy).toBeCalledTimes(1)
expect(updateStatisticsSpy).toBeCalledWith('aaa', '')
// expect(updateStatisticsSpy).toBeCalledTimes(1)
// expect(updateStatisticsSpy).toBeCalledWith('aaa', '')
})

test('url does not exist in neither cache nor db', async () => {
Expand Down Expand Up @@ -411,8 +411,8 @@ describe('redirect API tests', () => {

expect(res.statusCode).toBe(302)
expect(res._getRedirectUrl()).toBe('aa')
expect(updateStatisticsSpy).toBeCalledTimes(1)
expect(updateStatisticsSpy).toBeCalledWith('aaa', '')
// expect(updateStatisticsSpy).toBeCalledTimes(1)
// expect(updateStatisticsSpy).toBeCalledWith('aaa', '')
})

test('both db and cache down', async () => {
Expand Down
5 changes: 3 additions & 2 deletions src/server/modules/redirect/services/RedirectService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ export class RedirectService {
const longUrl = await this.urlRepository.getLongUrl(shortUrl)

// Update clicks and click statistics in database.
this.linkStatisticsService.updateLinkStatistics(shortUrl, userAgent)

if (false) {

Check warning on line 57 in src/server/modules/redirect/services/RedirectService.ts

View workflow job for this annotation

GitHub Actions / CI

Unexpected constant condition
this.linkStatisticsService.updateLinkStatistics(shortUrl, userAgent)
}
if (this.crawlerCheckService.isCrawler(userAgent)) {
return {
longUrl,
Expand Down

0 comments on commit 7cf0e5d

Please sign in to comment.