mirror of
https://github.com/penpot/penpot.git
synced 2025-04-13 23:41:24 -05:00
✨ Strip incoming changes from update-file response.
Until now, `update-file` always returned a ordered set of change-groups plus the one created by the ongoing request. A change-group corresponds to a list of changes commited in a single update-file (file_change table row). Including the ongoing request change-group on response with increase load stated causing considerable amount of memmory pressure. Since this changes are no longer necessary on frontend side, with this commit we strip the changes list from the ongoing request change-group, sending back an empty entry with the increased `revn` number.
This commit is contained in:
parent
840430c189
commit
4928f875b3
1 changed files with 18 additions and 14 deletions
|
@ -332,6 +332,24 @@
|
|||
;; Retrieve and return lagged data
|
||||
(retrieve-lagged-changes conn params))))
|
||||
|
||||
(def ^:private
|
||||
sql:lagged-changes
|
||||
"select s.id, s.revn, s.file_id,
|
||||
s.session_id, s.changes
|
||||
from file_change as s
|
||||
where s.file_id = ?
|
||||
and s.revn > ?
|
||||
order by s.created_at asc")
|
||||
|
||||
(defn- retrieve-lagged-changes
|
||||
[conn params]
|
||||
(->> (db/exec! conn [sql:lagged-changes (:id params) (:revn params)])
|
||||
(into [] (comp (map files/decode-row)
|
||||
(map (fn [row]
|
||||
(cond-> row
|
||||
(= (:revn row) (:revn (:file params)))
|
||||
(assoc :changes []))))))))
|
||||
|
||||
(defn- send-notifications
|
||||
[{:keys [msgbus conn] :as cfg} {:keys [file changes session-id] :as params}]
|
||||
(let [lchanges (filter library-change? changes)]
|
||||
|
@ -363,17 +381,3 @@
|
|||
[conn project-id]
|
||||
(:team-id (db/get-by-id conn :project project-id {:columns [:team-id]})))
|
||||
|
||||
(def ^:private
|
||||
sql:lagged-changes
|
||||
"select s.id, s.revn, s.file_id,
|
||||
s.session_id, s.changes
|
||||
from file_change as s
|
||||
where s.file_id = ?
|
||||
and s.revn > ?
|
||||
order by s.created_at asc")
|
||||
|
||||
(defn- retrieve-lagged-changes
|
||||
[conn params]
|
||||
(->> (db/exec! conn [sql:lagged-changes (:id params) (:revn params)])
|
||||
(mapv files/decode-row)))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue