Skip to content

Commit e8cfcf3

Browse files
committed
fix: App crash issue due to duplicate front entries
1 parent 048986a commit e8cfcf3

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

‎lib/octocon/fronts.ex‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ defmodule Octocon.Fronts do
9393
alter = Map.get(alters, front.alter_id, %{})
9494
%{front: front, alter: alter}
9595
end)
96+
|> Enum.filter(fn x -> x.alter != %{} end)
9697
|> sort_fronts(primary_front)
9798
end
9899

@@ -570,11 +571,17 @@ defmodule Octocon.Fronts do
570571
where: f.user_id == ^system_id and f.alter_id == ^alter_id,
571572
select: {f.id, f.time_start}
572573
)
573-
|> Repo.all()
574+
|> Repo.all_regional({:user, system_identity})
574575

575576
front_ids = Enum.map(fronts, &elem(&1, 0))
576577
front_time_starts = Enum.map(fronts, &elem(&1, 1))
577578

579+
from(
580+
f in CurrentFront,
581+
where: f.user_id == ^system_id and f.alter_id == ^alter_id
582+
)
583+
|> Repo.delete_all_regional({:user, system_identity})
584+
578585
from(
579586
f in Front,
580587
where: f.user_id == ^system_id and f.id in ^front_ids and f.time_start in ^front_time_starts

0 commit comments

Comments
 (0)