-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
293 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.DS_Store | ||
/.build | ||
/Packages | ||
xcuserdata/ | ||
DerivedData/ | ||
.swiftpm/configuration/registries.json | ||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata | ||
.netrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"originHash" : "d21c129c4ed8fa4634fe7ff3550a3ae14e9eda6d1d7d01017d1e369a1fc23826", | ||
"pins" : [ | ||
{ | ||
"identity" : "grdb.swift", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/groue/GRDB.swift.git", | ||
"state" : { | ||
"branch" : "GRDB7", | ||
"revision" : "3ecb5c54553559217592d21a6d9841becb891b38" | ||
} | ||
}, | ||
{ | ||
"identity" : "gtfs", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/emma-k-alexandra/GTFS.git", | ||
"state" : { | ||
"revision" : "92197f4c41aba53889a2db1e2e9d6dbe4022a223", | ||
"version" : "1.0.1" | ||
} | ||
}, | ||
{ | ||
"identity" : "swift-protobuf", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/apple/swift-protobuf.git", | ||
"state" : { | ||
"revision" : "ebc7251dd5b37f627c93698e4374084d98409633", | ||
"version" : "1.28.2" | ||
} | ||
} | ||
], | ||
"version" : 3 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// swift-tools-version: 6.0 | ||
// The swift-tools-version declares the minimum version of Swift required to build this package. | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "gtfs-db-swift", | ||
defaultLocalization: "en", // for tests | ||
platforms: [ | ||
.iOS(.v13), | ||
.macOS(.v10_15), | ||
.tvOS(.v13), | ||
.watchOS(.v7), | ||
], | ||
products: [ | ||
// Products define the executables and libraries a package produces, making them visible to other packages. | ||
.library( | ||
name: "GtfsDb", | ||
targets: ["GtfsDb"]), | ||
], | ||
dependencies: [ | ||
.package(url: "https://github.com/groue/GRDB.swift.git", branch: "GRDB7"), | ||
.package(url: "https://github.com/emma-k-alexandra/GTFS.git", .upToNextMajor(from: "1.0.1")) | ||
], | ||
targets: [ | ||
// Targets are the basic building blocks of a package, defining a module or a test suite. | ||
// Targets can depend on other targets in this package and products from dependencies. | ||
.target( | ||
name: "GtfsDb", | ||
dependencies: [.product(name: "GRDB", package: "grdb.swift"), "GTFS"]), | ||
.testTarget( | ||
name: "GtfsDbTests", | ||
dependencies: ["GtfsDb"] | ||
), | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// The Swift Programming Language | ||
// https://docs.swift.org/swift-book |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import Foundation | ||
import GRDB | ||
@preconcurrency import GTFS | ||
|
||
extension Agency: @retroactive @unchecked Sendable, @retroactive FetchableRecord, @retroactive TableRecord { | ||
public static var databaseTableName: String { "agency" } | ||
public static let databaseColumnDecodingStrategy = DatabaseColumnDecodingStrategy.convertFromSnakeCase | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import Foundation | ||
import GRDB | ||
@preconcurrency import GTFS | ||
|
||
extension Attribution: @retroactive @unchecked Sendable, @retroactive FetchableRecord, @retroactive TableRecord { | ||
public static var databaseTableName: String { "attributions" } | ||
public static let databaseColumnDecodingStrategy = DatabaseColumnDecodingStrategy.convertFromSnakeCase | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import Foundation | ||
import GRDB | ||
@preconcurrency import GTFS | ||
|
||
extension CalendarDate: @retroactive @unchecked Sendable, @retroactive FetchableRecord, @retroactive TableRecord { | ||
public static var databaseTableName: String { "calendar_dates" } | ||
public static let databaseColumnDecodingStrategy = DatabaseColumnDecodingStrategy.convertFromSnakeCase | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import Foundation | ||
import GRDB | ||
@preconcurrency import GTFS | ||
|
||
extension FareRule: @retroactive @unchecked Sendable, @retroactive FetchableRecord, @retroactive TableRecord { | ||
public static var databaseTableName: String { "fare_rules" } | ||
public static let databaseColumnDecodingStrategy = DatabaseColumnDecodingStrategy.convertFromSnakeCase | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import Foundation | ||
import GRDB | ||
@preconcurrency import GTFS | ||
|
||
extension FeedInfo: @retroactive @unchecked Sendable, @retroactive FetchableRecord, @retroactive TableRecord { | ||
public static var databaseTableName: String { "feed_info" } | ||
public static let databaseColumnDecodingStrategy = DatabaseColumnDecodingStrategy.convertFromSnakeCase | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import Foundation | ||
import GRDB | ||
@preconcurrency import GTFS | ||
|
||
extension Frequency: @retroactive @unchecked Sendable, @retroactive FetchableRecord, @retroactive TableRecord { | ||
public static var databaseTableName: String { "frequencies" } | ||
public static let databaseColumnDecodingStrategy = DatabaseColumnDecodingStrategy.convertFromSnakeCase | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import Foundation | ||
import GRDB | ||
@preconcurrency import GTFS | ||
|
||
extension GTFSCalendar: @retroactive @unchecked Sendable, @retroactive FetchableRecord, @retroactive TableRecord { | ||
public static var databaseTableName: String { "calendar" } | ||
public static let databaseColumnDecodingStrategy = DatabaseColumnDecodingStrategy.convertFromSnakeCase | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Foundation | ||
import GRDB | ||
@preconcurrency import GTFS | ||
|
||
extension Pathway: @retroactive @unchecked Sendable, @retroactive FetchableRecord, @retroactive TableRecord { | ||
public static var databaseTableName: String { "pathways" } | ||
public static let databaseColumnDecodingStrategy = DatabaseColumnDecodingStrategy.convertFromSnakeCase | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Foundation | ||
import GRDB | ||
@preconcurrency import GTFS | ||
|
||
extension Route: @retroactive @unchecked Sendable, @retroactive FetchableRecord, @retroactive TableRecord { | ||
public static var databaseTableName: String { "routes" } | ||
public static let databaseColumnDecodingStrategy = DatabaseColumnDecodingStrategy.convertFromSnakeCase | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import Foundation | ||
import GRDB | ||
@preconcurrency import GTFS | ||
|
||
extension Shape: @retroactive @unchecked Sendable, @retroactive FetchableRecord, @retroactive TableRecord { | ||
public static var databaseTableName: String { "shapes" } | ||
public static let databaseColumnDecodingStrategy = DatabaseColumnDecodingStrategy.convertFromSnakeCase | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import Foundation | ||
import GRDB | ||
@preconcurrency import GTFS | ||
|
||
extension Stop: @retroactive @unchecked Sendable, @retroactive FetchableRecord, @retroactive TableRecord { | ||
public static var databaseTableName: String { "stops" } | ||
public static let databaseColumnDecodingStrategy = DatabaseColumnDecodingStrategy.convertFromSnakeCase | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import Foundation | ||
import GRDB | ||
@preconcurrency import GTFS | ||
|
||
extension StopTime: @retroactive @unchecked Sendable, @retroactive FetchableRecord, @retroactive TableRecord { | ||
public static var databaseTableName: String { "stop_times" } | ||
public static let databaseColumnDecodingStrategy = DatabaseColumnDecodingStrategy.convertFromSnakeCase | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import Foundation | ||
import GRDB | ||
@preconcurrency import GTFS | ||
|
||
extension Transfer: @retroactive @unchecked Sendable, @retroactive FetchableRecord, @retroactive TableRecord { | ||
public static var databaseTableName: String { "transfers" } | ||
public static let databaseColumnDecodingStrategy = DatabaseColumnDecodingStrategy.convertFromSnakeCase | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import Foundation | ||
import GRDB | ||
@preconcurrency import GTFS | ||
|
||
extension Translation: @retroactive @unchecked Sendable, @retroactive FetchableRecord, @retroactive TableRecord { | ||
public static var databaseTableName: String { "translations" } | ||
public static let databaseColumnDecodingStrategy = DatabaseColumnDecodingStrategy.convertFromSnakeCase | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import Foundation | ||
import GRDB | ||
@preconcurrency import GTFS | ||
|
||
extension Trip: @retroactive @unchecked Sendable, @retroactive FetchableRecord, @retroactive TableRecord { | ||
public static var databaseTableName: String { "trips" } | ||
public static let databaseColumnDecodingStrategy = DatabaseColumnDecodingStrategy.convertFromSnakeCase | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import Testing | ||
import GRDB | ||
import GTFS | ||
@testable import GtfsDb | ||
|
||
@Suite("GTFS table count tests") | ||
struct GtfsDbTests { | ||
static let dbPath = "/Users/ffeli/Source/PhilipSoftware/BusCyprus/NPT_9_google_transit.sqlite" | ||
var dbQueue: DatabaseQueue | ||
|
||
init() throws { | ||
var config = Configuration() | ||
config.readonly = true | ||
dbQueue = try DatabaseQueue(path: GtfsDbTests.dbPath, configuration: config) | ||
} | ||
|
||
@Test func read_agencies() async throws { | ||
let count = try await dbQueue.read { db in try Agency.fetchCount(db) } | ||
print("agencies", count) | ||
} | ||
|
||
@Test func read_routes() async throws { | ||
let count = try await dbQueue.read { db in try Route.fetchCount(db) } | ||
print("routes", count) | ||
} | ||
|
||
@Test func read_stops() async throws { | ||
let count = try await dbQueue.read { db in try Stop.fetchCount(db) } | ||
print("stops", count) | ||
} | ||
|
||
@Test func read_trips() async throws { | ||
let count = try await dbQueue.read { db in try Trip.fetchCount(db) } | ||
print("trips", count) | ||
} | ||
|
||
@Test func read_stop_times() async throws { | ||
let count = try await dbQueue.read { db in try StopTime.fetchCount(db) } | ||
print("stop_times", count) | ||
} | ||
|
||
@Test func read_calendar() async throws { | ||
let count = try await dbQueue.read { db in try GTFSCalendar.fetchCount(db) } | ||
print("calendar", count) | ||
} | ||
|
||
@Test func read_calendar_dates() async throws { | ||
let count = try await dbQueue.read { db in try CalendarDate.fetchCount(db) } | ||
print("calendar_dates", count) | ||
} | ||
|
||
@Test func read_fare_rules() async throws { | ||
let count = try await dbQueue.read { db in try FareRule.fetchCount(db) } | ||
print("fare_rules", count) | ||
} | ||
|
||
@Test func read_shapes() async throws { | ||
let count = try await dbQueue.read { db in try Shape.fetchCount(db) } | ||
print("shapes", count) | ||
} | ||
|
||
@Test func read_frequencies() async throws { | ||
let count = try await dbQueue.read { db in try Frequency.fetchCount(db) } | ||
print("frequencies", count) | ||
} | ||
|
||
@Test func read_transfers() async throws { | ||
let count = try await dbQueue.read { db in try Transfer.fetchCount(db) } | ||
print("transfers", count) | ||
} | ||
|
||
@Test func read_pathways() async throws { | ||
let count = try await dbQueue.read { db in try Pathway.fetchCount(db) } | ||
print("pathways", count) | ||
} | ||
|
||
@Test func read_feed_info() async throws { | ||
let count = try await dbQueue.read { db in try FeedInfo.fetchCount(db) } | ||
print("feed_info", count) | ||
} | ||
|
||
@Test func read_translations() async throws { | ||
let count = try await dbQueue.read { db in try Translation.fetchCount(db) } | ||
print("translations", count) | ||
} | ||
|
||
@Test func read_attributions() async throws { | ||
let count = try await dbQueue.read { db in try Attribution.fetchCount(db) } | ||
print("attributions", count) | ||
} | ||
|
||
} |