| 218 | } |
| 219 | |
| 220 | public FetchObservables(): Stream[] { |
| 221 | const observables: Map<string, Stream> = new Map(); |
| 222 | const observablesPluginsStmt = this.db.prepare('SELECT o.url as url, p.name as plugin, o.lastSeen as lastSeen \ |
| 223 | FROM observablePlugins op \ |
| 224 | LEFT JOIN plugins p ON op.plugin = p.id \ |
| 225 | LEFT JOIN observables o ON op.observable = o.id \ |
| 226 | ORDER BY o.url, op.priority'); |
| 227 | const observablesPlugins = observablesPluginsStmt.all(); |
| 228 | |
| 229 | observablesPlugins.forEach((x: StreamRecord) => { |
| 230 | const obs = observables.get(x.url); |
| 231 | |
| 232 | if (obs) { |
| 233 | obs.plugins.push(x.plugin); |
| 234 | } else { |
| 235 | observables.set(x.url, { url: x.url, lastSeen: x.lastSeen, plugins: [x.plugin] }); |
| 236 | } |
| 237 | }); |
| 238 | |
| 239 | return [...observables.values()]; |
| 240 | } |
| 241 | |
| 242 | public FetchPlugins(): PluginRecord[] { |
| 243 | const pluginsStmt = this.db.prepare('SELECT id, name, enabled FROM plugins ORDER BY priority'); |