perf(settings): batch and deduplicate writes and persist panel dimensions
This commit is contained in:
1 parent
bc3fdd6119
commit
02413383d8
23 files changed
+869
-83
No files matched your search
@@ -60,32 +60,29 @@ class DriftAgentSettingsRepository implements AgentSettingsRepository {
|
||||
_database.transaction(() async {
|
||||
await _database.delete(_database.agentModels).go();
|
||||
await _database.delete(_database.agentProviders).go();
|
||||
for (final provider in settings.providers) {
|
||||
await _database
|
||||
.into(_database.agentProviders)
|
||||
.insert(
|
||||
AgentProvidersCompanion.insert(
|
||||
id: provider.id,
|
||||
enabled: Value(provider.enabled),
|
||||
name: provider.name,
|
||||
apiType: provider.apiType,
|
||||
baseUrl: provider.baseUrl,
|
||||
credentialId: Value(provider.credentialId),
|
||||
await _database.batch((batch) {
|
||||
batch.insertAll(_database.agentProviders, [
|
||||
for (final provider in settings.providers)
|
||||
AgentProvidersCompanion.insert(
|
||||
id: provider.id,
|
||||
enabled: Value(provider.enabled),
|
||||
name: provider.name,
|
||||
apiType: provider.apiType,
|
||||
baseUrl: provider.baseUrl,
|
||||
credentialId: Value(provider.credentialId),
|
||||
),
|
||||
]);
|
||||
batch.insertAll(_database.agentModels, [
|
||||
for (final provider in settings.providers)
|
||||
for (final model in provider.models)
|
||||
AgentModelsCompanion.insert(
|
||||
providerId: provider.id,
|
||||
modelId: model.id,
|
||||
contextWindow: Value(model.contextWindow),
|
||||
maxOutputTokens: Value(model.maxOutputTokens),
|
||||
),
|
||||
);
|
||||
for (final model in provider.models) {
|
||||
await _database
|
||||
.into(_database.agentModels)
|
||||
.insert(
|
||||
AgentModelsCompanion.insert(
|
||||
providerId: provider.id,
|
||||
modelId: model.id,
|
||||
contextWindow: Value(model.contextWindow),
|
||||
maxOutputTokens: Value(model.maxOutputTokens),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
]);
|
||||
});
|
||||
await _database
|
||||
.into(_database.agentConfigurations)
|
||||
.insertOnConflictUpdate(
|
||||
|
||||
Reference in new issue
Block a user