Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions open-api/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"info": {
"title": "RaidHub API",
"description": "The Semi-public API for RaidHub",
"version": "1.3.2",
"version": "1.3.3",
"contact": {
"name": "RaidHub Admin",
"email": "admin@raidhub.io"
Expand Down Expand Up @@ -500,7 +500,12 @@
},
"reportSource": {
"type": "string",
"enum": ["Manual", "CheatCheck", "WebReport"]
"enum": [
"Manual",
"CheatCheck",
"WebReport",
"BlacklistedPlayerCascade"
]
},
"reportId": {
"type": "integer",
Expand Down
2 changes: 1 addition & 1 deletion src/core/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const apiVersion = "1.3.2"
export const apiVersion = "1.3.3"
3 changes: 2 additions & 1 deletion src/schema/components/InstanceStanding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { zPlayerInfo } from "./PlayerInfo"
enum ReportSource {
Manual = "Manual",
CheatCheck = "CheatCheck",
WebReport = "WebReport"
WebReport = "WebReport",
BlacklistedPlayerCascade = "BlacklistedPlayerCascade"
}

enum CheatFlagIndex {
Expand Down
2 changes: 1 addition & 1 deletion src/services/atlas/atlas.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,6 @@ describe("getAtlasStatus no mock", () => {
const result = await getAtlasStatus()

expect(result.isCrawling).toBeTrue()
expect(result.lag).toBeWithin(25, 45)
expect(result.lag).toBeWithin(15, 60)
})
})
30 changes: 30 additions & 0 deletions src/services/instance/instance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,36 @@ describe("getInstance", () => {
expect(parsed.success).toBe(true)
}
})
describe("edge cases", () => {
it("is day one for day 1 clears on contest tdp", async () => {
const data = await getInstance("16321449037").catch(console.error)
const parsed = zInstance.safeParse(data)
if (!parsed.success) {
console.error(parsed.error.errors)
expect(parsed.error.errors).toEqual([])
} else {
expect(parsed.success).toBe(true)
expect(parsed.data.isContest).toBe(true)
expect(parsed.data.isDayOne).toBe(true)
expect(parsed.data.isWeekOne).toBe(true)
}
})

it("is not contest or day one for day 1 clears on non-contest tdp", async () => {
const data = await getInstance("16322031067").catch(console.error)

const parsed = zInstance.safeParse(data)
if (!parsed.success) {
console.error(parsed.error.errors)
expect(parsed.error.errors).toEqual([])
} else {
expect(parsed.success).toBe(true)
expect(parsed.data.isContest).toBe(false)
expect(parsed.data.isDayOne).toBe(false)
expect(parsed.data.isWeekOne).toBe(true)
}
})
})
})

describe("getInstanceExtended", () => {
Expand Down
8 changes: 4 additions & 4 deletions src/services/instance/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ export async function getInstance(instanceId: bigint | string): Promise<Instance
season_id AS "season",
duration AS "duration",
platform_type AS "platformType",
date_completed < COALESCE(day_one_end, TIMESTAMP 'epoch') AS "isDayOne",
date_completed < COALESCE(contest_end, TIMESTAMP 'epoch') AS "isContest",
CASE WHEN av.is_world_first THEN date_completed < COALESCE(day_one_end, TIMESTAMP 'epoch') ELSE false END AS "isDayOne",
CASE WHEN av.is_world_first THEN date_completed < COALESCE(contest_end, TIMESTAMP 'epoch') ELSE false END AS "isContest",
date_completed < COALESCE(week_one_end, TIMESTAMP 'epoch') AS "isWeekOne",
b.instance_id IS NOT NULL AS "isBlacklisted"
FROM instance
INNER JOIN activity_version USING (hash)
INNER JOIN activity_definition ON activity_definition.id = activity_version.activity_id
INNER JOIN activity_version av USING (hash)
INNER JOIN activity_definition ON activity_definition.id = av.activity_id
LEFT JOIN blacklist_instance b USING (instance_id)
WHERE instance_id = $1::bigint
LIMIT 1;`,
Expand Down
8 changes: 4 additions & 4 deletions src/services/player-instances/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ export const getActivities = async (
season_id AS "season",
duration AS "duration",
platform_type AS "platformType",
date_completed < COALESCE(day_one_end, TIMESTAMP 'epoch') AS "isDayOne",
date_completed < COALESCE(contest_end, TIMESTAMP 'epoch') AS "isContest",
CASE WHEN av.is_world_first THEN date_completed < COALESCE(day_one_end, TIMESTAMP 'epoch') ELSE false END AS "isDayOne",
CASE WHEN av.is_world_first THEN date_completed < COALESCE(contest_end, TIMESTAMP 'epoch') ELSE false END AS "isContest",
date_completed < COALESCE(week_one_end, TIMESTAMP 'epoch') AS "isWeekOne",
bi.instance_id IS NOT NULL AS "isBlacklisted",
JSONB_BUILD_OBJECT(
Expand All @@ -54,8 +54,8 @@ export const getActivities = async (
FROM instance_player
INNER JOIN instance USING (instance_id)
LEFT JOIN blacklist_instance bi USING (instance_id)
INNER JOIN activity_version USING (hash)
INNER JOIN activity_definition ON activity_definition.id = activity_version.activity_id
INNER JOIN activity_version av USING (hash)
INNER JOIN activity_definition ON activity_definition.id = av.activity_id
WHERE membership_id = $1::bigint
${cursor ? "AND date_completed < $3" : ""}
${cutoff ? "AND date_completed > $4" : ""}
Expand Down
8 changes: 4 additions & 4 deletions src/services/player-instances/instances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,15 @@ export async function getInstances({
season_id AS "season",
duration AS "duration",
platform_type AS "platformType",
date_completed < COALESCE(day_one_end, TIMESTAMP 'epoch') AS "isDayOne",
date_completed < COALESCE(contest_end, TIMESTAMP 'epoch') AS "isContest",
CASE WHEN av.is_world_first THEN date_completed < COALESCE(day_one_end, TIMESTAMP 'epoch') ELSE false END AS "isDayOne",
CASE WHEN av.is_world_first THEN date_completed < COALESCE(contest_end, TIMESTAMP 'epoch') ELSE false END AS "isContest",
date_completed < COALESCE(week_one_end, TIMESTAMP 'epoch') AS "isWeekOne",
b.instance_id IS NOT NULL AS "isBlacklisted",
"_lateral".players AS "players"
FROM _player_instances
INNER JOIN instance USING (instance_id)
INNER JOIN activity_version USING (hash)
INNER JOIN activity_definition ON activity_definition.id = activity_version.activity_id
INNER JOIN activity_version av USING (hash)
INNER JOIN activity_definition ON activity_definition.id = av.activity_id
LEFT JOIN blacklist_instance b USING (instance_id)
LEFT JOIN LATERAL (
SELECT
Expand Down
10 changes: 5 additions & 5 deletions src/services/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export const getPlayerActivityStats = async (membershipId: bigint | string) => {
THEN JSONB_BUILD_OBJECT(
'instanceId', fastest.instance_id::text,
'hash', fastest.hash,
'activityId', fastest_ah.activity_id,
'versionId', fastest_ah.version_id,
'activityId', av.activity_id,
'versionId', av.version_id,
'completed', fastest.completed,
'playerCount', fastest.player_count,
'score', fastest.score,
Expand All @@ -56,8 +56,8 @@ export const getPlayerActivityStats = async (membershipId: bigint | string) => {
'season', fastest.season_id,
'duration', fastest.duration,
'platformType', fastest.platform_type,
'isDayOne', date_completed < COALESCE(day_one_end, TIMESTAMP 'epoch'),
'isContest', date_completed < COALESCE(contest_end, TIMESTAMP 'epoch'),
'isDayOne', CASE WHEN av.is_world_first THEN date_completed < COALESCE(day_one_end, TIMESTAMP 'epoch') ELSE false END,
'isContest', CASE WHEN av.is_world_first THEN date_completed < COALESCE(contest_end, TIMESTAMP 'epoch') ELSE false END,
'isWeekOne', date_completed < COALESCE(week_one_end, TIMESTAMP 'epoch'),
'isBlacklisted', bi.instance_id IS NOT NULL
)
Expand All @@ -68,7 +68,7 @@ export const getPlayerActivityStats = async (membershipId: bigint | string) => {
AND player_stats.membership_id = $1::bigint
LEFT JOIN instance fastest ON player_stats.fastest_instance_id = fastest.instance_id
LEFT JOIN blacklist_instance bi ON player_stats.fastest_instance_id = bi.instance_id
LEFT JOIN activity_version fastest_ah ON fastest.hash = fastest_ah.hash
LEFT JOIN activity_version av ON fastest.hash = av.hash
ORDER BY activity_definition.id`,
{
params: [membershipId],
Expand Down
Loading