Skip to content

Commit 43efbb0

Browse files
committed
autoupdater refreshes repos
Squashed commit of the following: commit 59fbc3a Author: Paul Etchells (defiler) <p.a.etchells@gmail.com> Date: Fri May 9 20:30:35 2025 +0200 fixed tests commit 9ee3580 Author: Paul Etchells (defiler) <p.a.etchells@gmail.com> Date: Thu May 8 17:57:44 2025 +0200 fixed multiple triggers commit 97acca3 Author: Paul Etchells (interceptor) <p.a.etchells@gmail.com> Date: Fri Apr 25 22:56:12 2025 +0200 code for autoupdater commit c6517f2 Author: Paul Etchells (interceptor) <p.a.etchells@gmail.com> Date: Wed Apr 23 23:31:21 2025 +0200 saves properties to backend commit 3970763 Author: Paul Etchells (interceptor) <p.a.etchells@gmail.com> Date: Wed Apr 23 21:44:24 2025 +0200 improved properties editor commit b6344ca Author: Paul Etchells (interceptor) <p.a.etchells@gmail.com> Date: Tue Apr 22 20:33:36 2025 +0200 db retrofit :o & properties editor commit b4118c7 Author: Paul Etchells (defiler) <p.a.etchells@gmail.com> Date: Mon Apr 14 13:11:31 2025 +0200 source properties config commit 74dffc8 Author: Paul Etchells (defiler) <p.a.etchells@gmail.com> Date: Sat Apr 12 01:10:02 2025 +0200 adding properties structs
1 parent 9b34035 commit 43efbb0

30 files changed

Lines changed: 742 additions & 111 deletions

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
*~
2-
.*.swp
3-
.*.swo
2+
*.swp
3+
*.swo
44
Session.vim
55

66
.task/

deployments/docker/initdb.d/nrtm4_schema.sql

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
--
44

55
-- Dumped from database version 17.4 (Debian 17.4-1.pgdg120+2)
6-
-- Dumped by pg_dump version 17.0
6+
-- Dumped by pg_dump version 17.4 (Ubuntu 17.4-1.pgdg24.04+2)
77

88
SET statement_timeout = 0;
99
SET lock_timeout = 0;
@@ -153,7 +153,8 @@ CREATE TABLE public.nrtm_source (
153153
notification_url text NOT NULL,
154154
label character varying(255) NOT NULL,
155155
status character varying(255) NOT NULL,
156-
created timestamp without time zone NOT NULL
156+
created timestamp without time zone NOT NULL,
157+
properties jsonb DEFAULT '{}'::jsonb NOT NULL
157158
);
158159

159160

@@ -207,11 +208,11 @@ ALTER TABLE ONLY public.nrtm_rpslobject
207208

208209

209210
--
210-
-- Name: nrtm_rpslobject rpslobject__source__type__primary_key__version__uid; Type: CONSTRAINT; Schema: public; Owner: -
211+
-- Name: nrtm_rpslobject rpslobject__source__type__primary_key__uid; Type: CONSTRAINT; Schema: public; Owner: -
211212
--
212213

213214
ALTER TABLE ONLY public.nrtm_rpslobject
214-
ADD CONSTRAINT rpslobject__source__type__primary_key__version__uid UNIQUE (source_id, object_type, primary_key, version);
215+
ADD CONSTRAINT rpslobject__source__type__primary_key__uid UNIQUE (source_id, object_type, primary_key);
215216

216217

217218
--

internal/nrtm4/persist/persistencemodel.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,27 @@ type NRTMSource struct {
1515
NotificationURL string
1616
Label string
1717
Status string
18+
Properties SourceProperties
1819
Created time.Time
1920
}
2021

22+
// SourceProperties configurable user properties per source
23+
type SourceProperties struct {
24+
UpdateMode UpdateMode
25+
AutoUpdateInterval int
26+
}
27+
28+
// UpdateMode what to do when a mirror is re-synced from a snapshot
29+
type UpdateMode int
30+
31+
const (
32+
33+
// UpdateModePreserve when a repo loses sync, relabel it then reinitialize from snapshot
34+
UpdateModePreserve UpdateMode = iota
35+
// UpdateModeReplace when a repo loses sync delete it then reinitialize from snapshot
36+
UpdateModeReplace
37+
)
38+
2139
// NRTMSourceDetails is a source with notification objects
2240
type NRTMSourceDetails struct {
2341
NRTMSource
@@ -32,6 +50,7 @@ func NewNRTMSource(notification NotificationJSON, label string, notificationURL
3250
Version: uint32(notification.SnapshotRef.Version),
3351
Label: label,
3452
NotificationURL: notificationURL,
53+
Properties: SourceProperties{},
3554
}
3655
}
3756

internal/nrtm4/pg/persist/nrtmsource.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ import (
1111
// NRTMSource pg database mapping for nrtm_source
1212
type NRTMSource struct {
1313
db.EntityManaged `em:"nrtm_source src"`
14-
ID uint64 `em:"-"`
15-
Source string `em:"-"`
16-
SessionID string `em:"-"`
17-
Version uint32 `em:"-"`
18-
NotificationURL string `em:"-"`
19-
Label string `em:"-"`
20-
Status string `em:"-"`
21-
Created time.Time `em:"-"`
14+
ID uint64 `em:"-"`
15+
Source string `em:"-"`
16+
SessionID string `em:"-"`
17+
Version uint32 `em:"-"`
18+
NotificationURL string `em:"-"`
19+
Label string `em:"-"`
20+
Status string `em:"-"`
21+
Properties persist.SourceProperties `em:"-"`
22+
Created time.Time `em:"-"`
2223
}
2324

2425
// NewNRTMSource is a shorthand function which prepares a source object for storage
@@ -32,6 +33,7 @@ func NewNRTMSource(source persist.NRTMSource) NRTMSource {
3233
NotificationURL: source.NotificationURL,
3334
Label: source.Label,
3435
Status: source.Status,
36+
Properties: source.Properties,
3537
Created: util.AppClock.Now(),
3638
}
3739
return sourceObj
@@ -47,6 +49,7 @@ func FromNRTMSource(source persist.NRTMSource) NRTMSource {
4749
NotificationURL: source.NotificationURL,
4850
Label: source.Label,
4951
Status: source.Status,
52+
Properties: source.Properties,
5053
Created: source.Created,
5154
}
5255
}
@@ -61,6 +64,7 @@ func (s *NRTMSource) AsNRTMSource() persist.NRTMSource {
6164
NotificationURL: s.NotificationURL,
6265
Label: s.Label,
6366
Status: s.Status,
67+
Properties: s.Properties,
6468
Created: s.Created,
6569
}
6670
}

internal/nrtm4/pg/persist/nrtmsource_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ func TestNRTMSourceMapping(t *testing.T) {
1111
}
1212

1313
func TestColumnNameConversionFromFieldTags(t *testing.T) {
14-
expected := [...]string{"id", "source", "session_id", "version", "notification_url", "label", "status", "created"}
14+
expected := [...]string{"id", "source", "session_id", "version", "notification_url", "label", "status", "properties", "created"}
1515
o := NRTMSource{}
1616
dtor := db.GetDescriptor(&o)
1717
names := dtor.ColumnNames()

0 commit comments

Comments
 (0)