fix: try getting own-system members first even when matching hid (#439)

this is a bandaid fix for an issue where queries matching only the hid index would get stuck forever
This commit is contained in:
rladenson 2022-04-06 00:19:35 -06:00 committed by GitHub
parent e0ed5b528e
commit 576b23bca5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -80,8 +80,34 @@ public static class ContextEntityArgumentsExt
}
// Finally (or if by-HID lookup is specified), try member HID parsing:
if (await ctx.Repository.GetMemberByHid(input, restrictToSystem) is PKMember memberByHid)
return memberByHid;
// For posterity:
// There was a bug that made `SELECT * FROM MEMBERS WHERE HID = $1` hang forever BUT
// `SELECT * FROM MEMBERS WHERE HID = $1 AND SYSTEM = $2` *doesn't* hang! So this is a bandaid for that
// If we are supposed to restrict it to a system anyway we can just do that
PKMember memberByHid = null;
if (restrictToSystem != null)
{
memberByHid = await ctx.Repository.GetMemberByHid(input, restrictToSystem);
if (memberByHid != null)
return memberByHid;
}
// otherwise we try the querier's system and if that doesn't work we do global
else
{
memberByHid = await ctx.Repository.GetMemberByHid(input, ctx.System?.Id);
if (memberByHid != null)
return memberByHid;
// ff ctx.System was null then this would be a duplicate of above and we don't want to run it again
if (ctx.System != null)
{
memberByHid = await ctx.Repository.GetMemberByHid(input);
if (memberByHid != null)
return memberByHid;
}
}
// We didn't find anything, so we return null.
return null;