mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-10 15:57:53 +00:00
refactor: add SqlKata for SQL generation, move connection handling into ModelRepository
This commit is contained in:
parent
6251d29abb
commit
92e45a07ff
60 changed files with 806 additions and 640 deletions
|
|
@ -29,8 +29,7 @@ namespace PluralKit.Bot
|
|||
.Distinct()
|
||||
.ToList();
|
||||
|
||||
await using var conn = await _db.Obtain();
|
||||
var existingGroups = (await _repo.GetMemberGroups(conn, target.Id).ToListAsync())
|
||||
var existingGroups = (await _repo.GetMemberGroups(target.Id).ToListAsync())
|
||||
.Select(g => g.Id)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
|
|
@ -43,7 +42,7 @@ namespace PluralKit.Bot
|
|||
.Where(group => !existingGroups.Contains(group))
|
||||
.ToList();
|
||||
|
||||
await _repo.AddGroupsToMember(conn, target.Id, toAction);
|
||||
await _repo.AddGroupsToMember(target.Id, toAction);
|
||||
}
|
||||
else if (op == Groups.AddRemoveOperation.Remove)
|
||||
{
|
||||
|
|
@ -51,7 +50,7 @@ namespace PluralKit.Bot
|
|||
.Where(group => existingGroups.Contains(group))
|
||||
.ToList();
|
||||
|
||||
await _repo.RemoveGroupsFromMember(conn, target.Id, toAction);
|
||||
await _repo.RemoveGroupsFromMember(target.Id, toAction);
|
||||
}
|
||||
else return; // otherwise toAction "may be unassigned"
|
||||
|
||||
|
|
@ -60,11 +59,9 @@ namespace PluralKit.Bot
|
|||
|
||||
public async Task List(Context ctx, PKMember target)
|
||||
{
|
||||
await using var conn = await _db.Obtain();
|
||||
|
||||
var pctx = ctx.LookupContextFor(target.System);
|
||||
|
||||
var groups = await _repo.GetMemberGroups(conn, target.Id)
|
||||
var groups = await _repo.GetMemberGroups(target.Id)
|
||||
.Where(g => g.Visibility.CanAccess(pctx))
|
||||
.OrderBy(g => g.Name, StringComparer.InvariantCultureIgnoreCase)
|
||||
.ToListAsync();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue