feat: keep the materials index in sync and add bm:materials-reindex
- the materials admin syncs after create and update and removes after delete, once the save transaction commits (UseMaterialIndex, set at Boot) - POST and PUT /api/v1/bm/materials sync after the transaction, DELETE removes the document (its statement has no primary key, so no callback) - bm:materials-reindex [--fresh] [--if-configured] ensures the index and syncs every material; it refuses without an engine and runs nightly at 04:15 with --if-configured - TestMaterialSearchAgainstDatabase (Postgres) is written for the final verification phase
This commit is contained in:
@@ -322,7 +322,8 @@ func (h *Handlers) UpdateMaterialAccess(w http.ResponseWriter, r *http.Request)
|
||||
// applyMaterialAccess writes a visibility and share change onto m inside
|
||||
// tx. A material with no author gets userID as author (the claim rule).
|
||||
// Only is_private and author_user_id are updated; the shares are replaced
|
||||
// when setShares.
|
||||
// when setShares. The search index holds none of these, so no caller syncs
|
||||
// after it.
|
||||
func applyMaterialAccess(tx *gorm.DB, m *models.Material, userID uint, isPrivate *bool, setShares bool, shares []uint) error {
|
||||
if m.AuthorUserID == nil {
|
||||
id := userID
|
||||
|
||||
Reference in New Issue
Block a user