Add extra profile metadata
This commit is contained in:
@@ -10,28 +10,52 @@ extension ProfileMapper on Profile {
|
||||
name: name,
|
||||
url: url,
|
||||
lastUpdate: lastUpdate,
|
||||
updateInterval: Value(options?.updateInterval),
|
||||
upload: Value(subInfo?.upload),
|
||||
download: Value(subInfo?.download),
|
||||
total: Value(subInfo?.total),
|
||||
expire: Value(subInfo?.expire),
|
||||
updateInterval: Value(updateInterval),
|
||||
webPageUrl: Value(extra?.webPageUrl),
|
||||
supportUrl: Value(extra?.supportUrl),
|
||||
);
|
||||
}
|
||||
|
||||
static Profile fromEntry(ProfileEntry entry) {
|
||||
static Profile fromEntry(ProfileEntry e) {
|
||||
ProfileOptions? options;
|
||||
if (e.updateInterval != null) {
|
||||
options = ProfileOptions(updateInterval: e.updateInterval!);
|
||||
}
|
||||
|
||||
SubscriptionInfo? subInfo;
|
||||
if (e.upload != null &&
|
||||
e.download != null &&
|
||||
e.total != null &&
|
||||
e.expire != null) {
|
||||
subInfo = SubscriptionInfo(
|
||||
upload: e.upload!,
|
||||
download: e.download!,
|
||||
total: e.total!,
|
||||
expire: e.expire!,
|
||||
);
|
||||
}
|
||||
|
||||
ProfileExtra? extra;
|
||||
if (e.webPageUrl != null || e.supportUrl != null) {
|
||||
extra = ProfileExtra(
|
||||
webPageUrl: e.webPageUrl,
|
||||
supportUrl: e.supportUrl,
|
||||
);
|
||||
}
|
||||
|
||||
return Profile(
|
||||
id: entry.id,
|
||||
active: entry.active,
|
||||
name: entry.name,
|
||||
url: entry.url,
|
||||
lastUpdate: entry.lastUpdate,
|
||||
updateInterval: entry.updateInterval,
|
||||
subInfo: SubscriptionInfo(
|
||||
upload: entry.upload,
|
||||
download: entry.download,
|
||||
total: entry.total,
|
||||
expire: entry.expire,
|
||||
),
|
||||
id: e.id,
|
||||
active: e.active,
|
||||
name: e.name,
|
||||
url: e.url,
|
||||
lastUpdate: e.lastUpdate,
|
||||
options: options,
|
||||
subInfo: subInfo,
|
||||
extra: extra,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,13 +7,15 @@ class ProfileEntries extends Table {
|
||||
BoolColumn get active => boolean()();
|
||||
TextColumn get name => text().withLength(min: 1)();
|
||||
TextColumn get url => text()();
|
||||
DateTimeColumn get lastUpdate => dateTime()();
|
||||
IntColumn get updateInterval =>
|
||||
integer().nullable().map(DurationTypeConverter())();
|
||||
IntColumn get upload => integer().nullable()();
|
||||
IntColumn get download => integer().nullable()();
|
||||
IntColumn get total => integer().nullable()();
|
||||
DateTimeColumn get expire => dateTime().nullable()();
|
||||
IntColumn get updateInterval =>
|
||||
integer().nullable().map(DurationTypeConverter())();
|
||||
DateTimeColumn get lastUpdate => dateTime()();
|
||||
TextColumn get webPageUrl => text().nullable()();
|
||||
TextColumn get supportUrl => text().nullable()();
|
||||
|
||||
@override
|
||||
Set<Column> get primaryKey => {id};
|
||||
|
||||
Reference in New Issue
Block a user