add poi type to feed item shape
This commit is contained in:
@@ -36,6 +36,7 @@ struct FeedItem: Codable, Equatable {
|
||||
let ttlSec: Int
|
||||
let condition: WeatherKit.WeatherCondition?
|
||||
let startsAt: Int?
|
||||
let poiType: POIDataSource.POIType?
|
||||
let bucket: Bucket
|
||||
let actions: [String]
|
||||
|
||||
@@ -48,6 +49,7 @@ struct FeedItem: Codable, Equatable {
|
||||
case ttlSec = "ttl_sec"
|
||||
case condition
|
||||
case startsAt = "starts_at"
|
||||
case poiType = "poi_type"
|
||||
case bucket
|
||||
case actions
|
||||
}
|
||||
@@ -60,6 +62,7 @@ struct FeedItem: Codable, Equatable {
|
||||
ttlSec: Int,
|
||||
condition: WeatherKit.WeatherCondition? = nil,
|
||||
startsAt: Int? = nil,
|
||||
poiType: POIDataSource.POIType? = nil,
|
||||
bucket: Bucket,
|
||||
actions: [String]) {
|
||||
self.id = id
|
||||
@@ -70,6 +73,7 @@ struct FeedItem: Codable, Equatable {
|
||||
self.ttlSec = ttlSec
|
||||
self.condition = condition
|
||||
self.startsAt = startsAt
|
||||
self.poiType = poiType
|
||||
self.bucket = bucket
|
||||
self.actions = actions
|
||||
}
|
||||
@@ -85,6 +89,11 @@ struct FeedItem: Codable, Equatable {
|
||||
bucket = try container.decode(Bucket.self, forKey: .bucket)
|
||||
actions = try container.decode([String].self, forKey: .actions)
|
||||
startsAt = try container.decodeIfPresent(Int.self, forKey: .startsAt)
|
||||
if let raw = try container.decodeIfPresent(String.self, forKey: .poiType) {
|
||||
poiType = POIDataSource.POIType(rawValue: raw) ?? .other
|
||||
} else {
|
||||
poiType = nil
|
||||
}
|
||||
|
||||
if let encoded = try container.decodeIfPresent(String.self, forKey: .condition) {
|
||||
condition = WeatherKit.WeatherCondition.irisDecode(encoded)
|
||||
@@ -104,6 +113,9 @@ struct FeedItem: Codable, Equatable {
|
||||
try container.encode(bucket, forKey: .bucket)
|
||||
try container.encode(actions, forKey: .actions)
|
||||
try container.encodeIfPresent(startsAt, forKey: .startsAt)
|
||||
if let poiType {
|
||||
try container.encode(poiType.rawValue, forKey: .poiType)
|
||||
}
|
||||
if let condition {
|
||||
try container.encode(condition.irisScreamingCase(), forKey: .condition)
|
||||
}
|
||||
|
||||
@@ -132,6 +132,7 @@ final class FeedStore {
|
||||
ttlSec: ttl,
|
||||
condition: card.condition,
|
||||
startsAt: card.startsAt,
|
||||
poiType: card.poiType,
|
||||
bucket: card.bucket,
|
||||
actions: card.actions
|
||||
)
|
||||
|
||||
@@ -75,6 +75,7 @@ final class HeuristicRanker {
|
||||
ttlSec: max(1, best.item.ttlSec),
|
||||
condition: best.item.condition,
|
||||
startsAt: best.item.startsAt,
|
||||
poiType: best.item.poiType,
|
||||
bucket: .rightNow,
|
||||
actions: ["DISMISS"]
|
||||
)
|
||||
|
||||
84
IrisCompanion/iris/Models/POIType.swift
Normal file
84
IrisCompanion/iris/Models/POIType.swift
Normal file
@@ -0,0 +1,84 @@
|
||||
//
|
||||
// POIType.swift
|
||||
// iris
|
||||
//
|
||||
// Created by Codex.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
enum POIType: String, Codable, CaseIterable, Sendable {
|
||||
case animalService = "MKPOICategoryAnimalService"
|
||||
case airport = "MKPOICategoryAirport"
|
||||
case amusementPark = "MKPOICategoryAmusementPark"
|
||||
case aquarium = "MKPOICategoryAquarium"
|
||||
case atm = "MKPOICategoryATM"
|
||||
case automotiveRepair = "MKPOICategoryAutomotiveRepair"
|
||||
case bakery = "MKPOICategoryBakery"
|
||||
case bank = "MKPOICategoryBank"
|
||||
case baseball = "MKPOICategoryBaseball"
|
||||
case basketball = "MKPOICategoryBasketball"
|
||||
case beach = "MKPOICategoryBeach"
|
||||
case beauty = "MKPOICategoryBeauty"
|
||||
case bowling = "MKPOICategoryBowling"
|
||||
case brewery = "MKPOICategoryBrewery"
|
||||
case cafe = "MKPOICategoryCafe"
|
||||
case campground = "MKPOICategoryCampground"
|
||||
case carRental = "MKPOICategoryCarRental"
|
||||
case castle = "MKPOICategoryCastle"
|
||||
case conventionCenter = "MKPOICategoryConventionCenter"
|
||||
case distillery = "MKPOICategoryDistillery"
|
||||
case evCharger = "MKPOICategoryEVCharger"
|
||||
case fairground = "MKPOICategoryFairground"
|
||||
case fireStation = "MKPOICategoryFireStation"
|
||||
case fishing = "MKPOICategoryFishing"
|
||||
case fitnessCenter = "MKPOICategoryFitnessCenter"
|
||||
case foodMarket = "MKPOICategoryFoodMarket"
|
||||
case fortress = "MKPOICategoryFortress"
|
||||
case gasStation = "MKPOICategoryGasStation"
|
||||
case golf = "MKPOICategoryGolf"
|
||||
case goKart = "MKPOICategoryGoKart"
|
||||
case hiking = "MKPOICategoryHiking"
|
||||
case hospital = "MKPOICategoryHospital"
|
||||
case hotel = "MKPOICategoryHotel"
|
||||
case kayaking = "MKPOICategoryKayaking"
|
||||
case landmark = "MKPOICategoryLandmark"
|
||||
case laundry = "MKPOICategoryLaundry"
|
||||
case library = "MKPOICategoryLibrary"
|
||||
case mailbox = "MKPOICategoryMailbox"
|
||||
case marina = "MKPOICategoryMarina"
|
||||
case miniGolf = "MKPOICategoryMiniGolf"
|
||||
case movieTheater = "MKPOICategoryMovieTheater"
|
||||
case museum = "MKPOICategoryMuseum"
|
||||
case musicVenue = "MKPOICategoryMusicVenue"
|
||||
case nationalMonument = "MKPOICategoryNationalMonument"
|
||||
case nationalPark = "MKPOICategoryNationalPark"
|
||||
case nightlife = "MKPOICategoryNightlife"
|
||||
case park = "MKPOICategoryPark"
|
||||
case parking = "MKPOICategoryParking"
|
||||
case pharmacy = "MKPOICategoryPharmacy"
|
||||
case planetarium = "MKPOICategoryPlanetarium"
|
||||
case police = "MKPOICategoryPolice"
|
||||
case postOffice = "MKPOICategoryPostOffice"
|
||||
case publicTransport = "MKPOICategoryPublicTransport"
|
||||
case restaurant = "MKPOICategoryRestaurant"
|
||||
case restroom = "MKPOICategoryRestroom"
|
||||
case rockClimbing = "MKPOICategoryRockClimbing"
|
||||
case rvPark = "MKPOICategoryRVPark"
|
||||
case school = "MKPOICategorySchool"
|
||||
case skatePark = "MKPOICategorySkatePark"
|
||||
case skating = "MKPOICategorySkating"
|
||||
case skiing = "MKPOICategorySkiing"
|
||||
case soccer = "MKPOICategorySoccer"
|
||||
case spa = "MKPOICategorySpa"
|
||||
case stadium = "MKPOICategoryStadium"
|
||||
case store = "MKPOICategoryStore"
|
||||
case surfing = "MKPOICategorySurfing"
|
||||
case swimming = "MKPOICategorySwimming"
|
||||
case tennis = "MKPOICategoryTennis"
|
||||
case theater = "MKPOICategoryTheater"
|
||||
case university = "MKPOICategoryUniversity"
|
||||
case winery = "MKPOICategoryWinery"
|
||||
case volleyball = "MKPOICategoryVolleyball"
|
||||
case zoo = "MKPOICategoryZoo"
|
||||
}
|
||||
Reference in New Issue
Block a user