Make Database.framework build. Doesn’t work, but it builds.

This commit is contained in:
Brent Simmons 2017-08-21 13:31:14 -07:00
parent 4010011b5a
commit 5860f774bd
5 changed files with 58 additions and 19 deletions

View File

@ -33,13 +33,13 @@ public final class Article: Hashable {
public var status: ArticleStatus?
public let hashValue: Int
var feed: Feed? {
public var feed: Feed? {
get {
return account?.existingFeed(with: feedID)
}
}
init(account: Account, articleID: String?, feedID: String, uniqueID: String, title: String?, contentHTML: String?, contentText: String?, url: String?, externalURL: String?, summary: String?, imageURL: String?, bannerImageURL: String?, datePublished: Date?, dateModified: Date?, authors: [Author]?, tags: Set<String>?, attachments: [Attachment]?, accountInfo: AccountInfo?) {
public init(account: Account, articleID: String?, feedID: String, uniqueID: String, title: String?, contentHTML: String?, contentText: String?, url: String?, externalURL: String?, summary: String?, imageURL: String?, bannerImageURL: String?, datePublished: Date?, dateModified: Date?, authors: [Author]?, tags: Set<String>?, attachments: [Attachment]?, accountInfo: AccountInfo?) {
self.account = account
self.feedID = feedID

View File

@ -10,17 +10,47 @@ import Foundation
import RSDatabase
import Data
//final class ArticlesTable: DatabaseTable {
//
// let name: String
final class ArticlesTable: DatabaseTable {
let name: String
let databaseIDKey = DatabaseKey.articleID
// private let cachedArticles: NSMapTable<NSString, Article> = NSMapTable.weakToWeakObjects()
//
// init(name: String) {
//
// self.name = name
// }
init(name: String) {
self.name = name
}
// MARK: DatabaseTable Methods
func objectWithRow(_ row: FMResultSet) -> DatabaseObject? {
// if let article = articleWithRow(row) {
//
// }
return nil // TODO
}
func save(_ objects: [DatabaseObject], in database: FMDatabase) {
// TODO
}
// MARK: Fetching
func fetchArticlesForFeed(_ feed: Feed) -> Set<Article> {
return Set<Article>() // TODO
}
func fetchArticlesForFeedAsync(_ feed: Feed, _ resultBlock: @escaping ArticleResultBlock) {
// TODO
}
func fetchUnreadArticlesForFeeds(_ feeds: Set<Feed>) -> Set<Article> {
return Set<Article>() // TODO
}
// func uniquedArticles(_ fetchedArticles: Set<Article>, statusesTable: StatusesTable) -> Set<Article> {
//
@ -67,7 +97,7 @@ import Data
// }
//
// }
//}
}
//private extension ArticlesTable {

View File

@ -26,7 +26,7 @@ final class Database {
private let queue: RSDatabaseQueue
private let databaseFile: String
// private let articlesTable: ArticlesTable
private let articlesTable: ArticlesTable
private let statusesTable: StatusesTable
private let authorsLookupTable: DatabaseLookupTable
private let attachmentsLookupTable: DatabaseLookupTable
@ -41,7 +41,7 @@ final class Database {
self.databaseFile = databaseFile
self.queue = RSDatabaseQueue(filepath: databaseFile, excludeFromBackup: false)
// self.articlesTable = ArticlesTable(name: DatabaseTableName.articles, queue: queue)
self.articlesTable = ArticlesTable(name: DatabaseTableName.articles)
self.statusesTable = StatusesTable(name: DatabaseTableName.statuses)
let authorsTable = AuthorsTable(name: DatabaseTableName.authors)
@ -63,7 +63,9 @@ final class Database {
func fetchArticlesForFeed(_ feed: Feed) -> Set<Article> {
return Set<Article>() // TODO
return articlesTable.fetchArticlesForFeed(feed)
// return Set<Article>() // TODO
// var fetchedArticles = Set<Article>()
// let feedID = feed.feedID
//
@ -78,6 +80,8 @@ final class Database {
func fetchArticlesForFeedAsync(_ feed: Feed, _ resultBlock: @escaping ArticleResultBlock) {
articlesTable.fetchArticlesForFeedAsync(feed, resultBlock)
// let feedID = feed.feedID
//
// queue.fetch { (database: FMDatabase!) -> Void in
@ -95,7 +99,7 @@ final class Database {
func fetchUnreadArticlesForFolder(_ folder: Folder) -> Set<Article> {
return Set<Article>() // TODO
return articlesTable.fetchUnreadArticlesForFeeds(folder.flattenedFeeds())
// return fetchUnreadArticlesForFeedIDs(folder.flattenedFeedIDs())
}

View File

@ -32,12 +32,17 @@ extension Article {
let bannerImageURL = row.string(forColumn: DatabaseKey.bannerImageURL)
let datePublished = row.date(forColumn: DatabaseKey.datePublished)
let dateModified = row.date(forColumn: DatabaseKey.dateModified)
let authors: [Author]? = nil
let tags: Set<String>? = nil
let attachments: [Attachment]? = nil
let accountInfo: [String: Any]? = nil
// let authors = PropertyListTransformer.authorsWithRow(row)
// let tags = PropertyListTransformer.tagsWithRow(row)
// let attachments = PropertyListTransformer.attachmentsWithRow(row)
// let accountInfo = accountInfoWithRow(row)
self.init(account: account, feedID: feedID, uniqueID: uniqueID, title: title, contentHTML: contentHTML, contentText: contentText, url: url, externalURL: externalURL, summary: summary, imageURL: imageURL, bannerImageURL: bannerImageURL, datePublished: datePublished, dateModified: dateModified, authors: authors, tags: tags, attachments: attachments, accountInfo: accountInfo)
self.init(account: account, articleID: articleID, feedID: feedID, uniqueID: uniqueID, title: title, contentHTML: contentHTML, contentText: contentText, url: url, externalURL: externalURL, summary: summary, imageURL: imageURL, bannerImageURL: bannerImageURL, datePublished: datePublished, dateModified: dateModified, authors: authors, tags: tags, attachments: attachments, accountInfo: accountInfo)
}
func databaseDictionary() -> NSDictionary {
@ -67,6 +72,6 @@ extension Set where Element == Article {
func articleIDs() -> Set<String> {
return Set(map { $0.databaseID })
return Set<String>(map { $0.databaseID })
}
}

View File

@ -565,7 +565,7 @@
INFOPLIST_FILE = RSDatabase/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
OTHER_SWIFT_FLAGS = "-Xfrontend -warn-long-function-bodies=125";
OTHER_SWIFT_FLAGS = "-Xfrontend -warn-long-function-bodies=200";
PRODUCT_BUNDLE_IDENTIFIER = com.ranchero.RSDatabase;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
@ -586,7 +586,7 @@
INFOPLIST_FILE = RSDatabase/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
OTHER_SWIFT_FLAGS = "-Xfrontend -warn-long-function-bodies=125";
OTHER_SWIFT_FLAGS = "-Xfrontend -warn-long-function-bodies=200";
PRODUCT_BUNDLE_IDENTIFIER = com.ranchero.RSDatabase;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;