mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-21 15:50:59 +00:00
Rename all "index" columns to "order"
This commit is contained in:
parent
2dae234849
commit
a6cbe6e96d
8 changed files with 19 additions and 17 deletions
|
@ -7,14 +7,14 @@ import Mastodon
|
|||
struct AccountPinnedStatusJoin: ContentDatabaseRecord {
|
||||
let accountId: Account.Id
|
||||
let statusId: Status.Id
|
||||
let index: Int
|
||||
let order: Int
|
||||
}
|
||||
|
||||
extension AccountPinnedStatusJoin {
|
||||
enum Columns {
|
||||
static let accountId = Column(CodingKeys.accountId)
|
||||
static let statusId = Column(CodingKeys.statusId)
|
||||
static let index = Column(CodingKeys.index)
|
||||
static let order = Column(CodingKeys.order)
|
||||
}
|
||||
|
||||
static let status = belongsTo(StatusRecord.self)
|
||||
|
|
|
@ -58,7 +58,7 @@ extension AccountRecord {
|
|||
static let identityProofs = hasMany(IdentityProofRecord.self)
|
||||
static let featuredTags = hasMany(FeaturedTagRecord.self)
|
||||
static let pinnedStatusJoins = hasMany(AccountPinnedStatusJoin.self)
|
||||
.order(AccountPinnedStatusJoin.Columns.index)
|
||||
.order(AccountPinnedStatusJoin.Columns.order)
|
||||
static let pinnedStatuses = hasMany(
|
||||
StatusRecord.self,
|
||||
through: pinnedStatusJoins,
|
||||
|
|
|
@ -226,7 +226,7 @@ extension ContentDatabase {
|
|||
.references("statusRecord", onDelete: .cascade)
|
||||
t.column("statusId", .text).indexed().notNull()
|
||||
.references("statusRecord", onDelete: .cascade)
|
||||
t.column("index", .integer).notNull()
|
||||
t.column("order", .integer).notNull()
|
||||
|
||||
t.primaryKey(["parentId", "statusId"], onConflict: .replace)
|
||||
}
|
||||
|
@ -236,7 +236,7 @@ extension ContentDatabase {
|
|||
.references("statusRecord", onDelete: .cascade)
|
||||
t.column("statusId", .text).indexed().notNull()
|
||||
.references("statusRecord", onDelete: .cascade)
|
||||
t.column("index", .integer).notNull()
|
||||
t.column("order", .integer).notNull()
|
||||
|
||||
t.primaryKey(["parentId", "statusId"], onConflict: .replace)
|
||||
}
|
||||
|
@ -246,7 +246,7 @@ extension ContentDatabase {
|
|||
.references("accountRecord", onDelete: .cascade)
|
||||
t.column("statusId", .text).indexed().notNull()
|
||||
.references("statusRecord", onDelete: .cascade)
|
||||
t.column("index", .integer).notNull()
|
||||
t.column("order", .integer).notNull()
|
||||
|
||||
t.primaryKey(["accountId", "statusId"], onConflict: .replace)
|
||||
}
|
||||
|
|
|
@ -135,12 +135,12 @@ public extension ContentDatabase {
|
|||
databaseWriter.writePublisher {
|
||||
for (index, status) in context.ancestors.enumerated() {
|
||||
try status.save($0)
|
||||
try StatusAncestorJoin(parentId: parentId, statusId: status.id, index: index).save($0)
|
||||
try StatusAncestorJoin(parentId: parentId, statusId: status.id, order: index).save($0)
|
||||
}
|
||||
|
||||
for (index, status) in context.descendants.enumerated() {
|
||||
try status.save($0)
|
||||
try StatusDescendantJoin(parentId: parentId, statusId: status.id, index: index).save($0)
|
||||
try StatusDescendantJoin(parentId: parentId, statusId: status.id, order: index).save($0)
|
||||
}
|
||||
|
||||
try StatusAncestorJoin.filter(
|
||||
|
@ -161,7 +161,7 @@ public extension ContentDatabase {
|
|||
databaseWriter.writePublisher {
|
||||
for (index, status) in pinnedStatuses.enumerated() {
|
||||
try status.save($0)
|
||||
try AccountPinnedStatusJoin(accountId: accountId, statusId: status.id, index: index).save($0)
|
||||
try AccountPinnedStatusJoin(accountId: accountId, statusId: status.id, order: index).save($0)
|
||||
}
|
||||
|
||||
try AccountPinnedStatusJoin.filter(
|
||||
|
|
|
@ -7,14 +7,14 @@ import Mastodon
|
|||
struct StatusAncestorJoin: ContentDatabaseRecord {
|
||||
let parentId: Status.Id
|
||||
let statusId: Status.Id
|
||||
let index: Int
|
||||
let order: Int
|
||||
}
|
||||
|
||||
extension StatusAncestorJoin {
|
||||
enum Columns {
|
||||
static let parentId = Column(CodingKeys.parentId)
|
||||
static let statusId = Column(CodingKeys.statusId)
|
||||
static let index = Column(CodingKeys.index)
|
||||
static let order = Column(CodingKeys.order)
|
||||
}
|
||||
|
||||
static let status = belongsTo(StatusRecord.self, using: ForeignKey([Columns.statusId]))
|
||||
|
|
|
@ -7,14 +7,14 @@ import Mastodon
|
|||
struct StatusDescendantJoin: ContentDatabaseRecord {
|
||||
let parentId: Status.Id
|
||||
let statusId: Status.Id
|
||||
let index: Int
|
||||
let order: Int
|
||||
}
|
||||
|
||||
extension StatusDescendantJoin {
|
||||
enum Columns {
|
||||
static let parentId = Column(CodingKeys.parentId)
|
||||
static let statusId = Column(CodingKeys.statusId)
|
||||
static let index = Column(CodingKeys.index)
|
||||
static let order = Column(CodingKeys.order)
|
||||
}
|
||||
|
||||
static let status = belongsTo(StatusRecord.self, using: ForeignKey([Columns.statusId]))
|
||||
|
|
|
@ -95,11 +95,11 @@ extension StatusRecord {
|
|||
static let ancestorJoins = hasMany(
|
||||
StatusAncestorJoin.self,
|
||||
using: ForeignKey([StatusAncestorJoin.Columns.parentId]))
|
||||
.order(StatusAncestorJoin.Columns.index)
|
||||
.order(StatusAncestorJoin.Columns.order)
|
||||
static let descendantJoins = hasMany(
|
||||
StatusDescendantJoin.self,
|
||||
using: ForeignKey([StatusDescendantJoin.Columns.parentId]))
|
||||
.order(StatusDescendantJoin.Columns.index)
|
||||
.order(StatusDescendantJoin.Columns.order)
|
||||
static let ancestors = hasMany(StatusRecord.self,
|
||||
through: ancestorJoins,
|
||||
using: StatusAncestorJoin.status)
|
||||
|
|
|
@ -17,7 +17,8 @@ extension TimelineItemsInfo {
|
|||
let pinnedStatusInfos: [StatusInfo]
|
||||
}
|
||||
|
||||
static func addingIncludes<T: DerivableRequest>( _ request: T, ordered: Bool) -> T where T.RowDecoder == TimelineRecord {
|
||||
static func addingIncludes<T: DerivableRequest>( _ request: T,
|
||||
ordered: Bool) -> T where T.RowDecoder == TimelineRecord {
|
||||
let statusesAssociation = ordered ? TimelineRecord.orderedStatuses : TimelineRecord.statuses
|
||||
|
||||
return request.including(all: StatusInfo.addingIncludes(statusesAssociation).forKey(CodingKeys.statusInfos))
|
||||
|
@ -26,7 +27,8 @@ extension TimelineItemsInfo {
|
|||
.forKey(CodingKeys.pinnedStatusesInfo))
|
||||
}
|
||||
|
||||
static func request(_ request: QueryInterfaceRequest<TimelineRecord>, ordered: Bool) -> QueryInterfaceRequest<Self> {
|
||||
static func request(_ request: QueryInterfaceRequest<TimelineRecord>,
|
||||
ordered: Bool) -> QueryInterfaceRequest<Self> {
|
||||
addingIncludes(request, ordered: ordered).asRequest(of: self)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue