Fix European trip return heuristic for weekend location tracking
Adjust European short trip heuristic from >3 days to >1 day to correctly detect when user has returned home from European trips. This fixes the April 29-30, 2023 case where the location incorrectly showed "Sankt Georg, Hamburg" instead of "Bristol" when the user was free (no events scheduled) after the foss-north trip ended on April 27. The previous logic required more than 3 days to pass before assuming return home from European countries, but for short European trips by rail/ferry, users typically return within 1-2 days. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
663dc479c2
commit
ea4980a5d7
6407 changed files with 1072847 additions and 18 deletions
7
node_modules/ajv/lib/vocabularies/unevaluated/index.ts
generated
vendored
Normal file
7
node_modules/ajv/lib/vocabularies/unevaluated/index.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import type {Vocabulary} from "../../types"
|
||||
import unevaluatedProperties from "./unevaluatedProperties"
|
||||
import unevaluatedItems from "./unevaluatedItems"
|
||||
|
||||
const unevaluated: Vocabulary = [unevaluatedProperties, unevaluatedItems]
|
||||
|
||||
export default unevaluated
|
||||
47
node_modules/ajv/lib/vocabularies/unevaluated/unevaluatedItems.ts
generated
vendored
Normal file
47
node_modules/ajv/lib/vocabularies/unevaluated/unevaluatedItems.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
import type {
|
||||
CodeKeywordDefinition,
|
||||
ErrorObject,
|
||||
KeywordErrorDefinition,
|
||||
AnySchema,
|
||||
} from "../../types"
|
||||
import type {KeywordCxt} from "../../compile/validate"
|
||||
import {_, str, not, Name} from "../../compile/codegen"
|
||||
import {alwaysValidSchema, Type} from "../../compile/util"
|
||||
|
||||
export type UnevaluatedItemsError = ErrorObject<"unevaluatedItems", {limit: number}, AnySchema>
|
||||
|
||||
const error: KeywordErrorDefinition = {
|
||||
message: ({params: {len}}) => str`must NOT have more than ${len} items`,
|
||||
params: ({params: {len}}) => _`{limit: ${len}}`,
|
||||
}
|
||||
|
||||
const def: CodeKeywordDefinition = {
|
||||
keyword: "unevaluatedItems",
|
||||
type: "array",
|
||||
schemaType: ["boolean", "object"],
|
||||
error,
|
||||
code(cxt: KeywordCxt) {
|
||||
const {gen, schema, data, it} = cxt
|
||||
const items = it.items || 0
|
||||
if (items === true) return
|
||||
const len = gen.const("len", _`${data}.length`)
|
||||
if (schema === false) {
|
||||
cxt.setParams({len: items})
|
||||
cxt.fail(_`${len} > ${items}`)
|
||||
} else if (typeof schema == "object" && !alwaysValidSchema(it, schema)) {
|
||||
const valid = gen.var("valid", _`${len} <= ${items}`)
|
||||
gen.if(not(valid), () => validateItems(valid, items))
|
||||
cxt.ok(valid)
|
||||
}
|
||||
it.items = true
|
||||
|
||||
function validateItems(valid: Name, from: Name | number): void {
|
||||
gen.forRange("i", from, len, (i) => {
|
||||
cxt.subschema({keyword: "unevaluatedItems", dataProp: i, dataPropType: Type.Num}, valid)
|
||||
if (!it.allErrors) gen.if(not(valid), () => gen.break())
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
export default def
|
||||
85
node_modules/ajv/lib/vocabularies/unevaluated/unevaluatedProperties.ts
generated
vendored
Normal file
85
node_modules/ajv/lib/vocabularies/unevaluated/unevaluatedProperties.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
import type {
|
||||
CodeKeywordDefinition,
|
||||
KeywordErrorDefinition,
|
||||
ErrorObject,
|
||||
AnySchema,
|
||||
} from "../../types"
|
||||
import {_, not, and, Name, Code} from "../../compile/codegen"
|
||||
import {alwaysValidSchema, Type} from "../../compile/util"
|
||||
import N from "../../compile/names"
|
||||
|
||||
export type UnevaluatedPropertiesError = ErrorObject<
|
||||
"unevaluatedProperties",
|
||||
{unevaluatedProperty: string},
|
||||
AnySchema
|
||||
>
|
||||
|
||||
const error: KeywordErrorDefinition = {
|
||||
message: "must NOT have unevaluated properties",
|
||||
params: ({params}) => _`{unevaluatedProperty: ${params.unevaluatedProperty}}`,
|
||||
}
|
||||
|
||||
const def: CodeKeywordDefinition = {
|
||||
keyword: "unevaluatedProperties",
|
||||
type: "object",
|
||||
schemaType: ["boolean", "object"],
|
||||
trackErrors: true,
|
||||
error,
|
||||
code(cxt) {
|
||||
const {gen, schema, data, errsCount, it} = cxt
|
||||
/* istanbul ignore if */
|
||||
if (!errsCount) throw new Error("ajv implementation error")
|
||||
const {allErrors, props} = it
|
||||
if (props instanceof Name) {
|
||||
gen.if(_`${props} !== true`, () =>
|
||||
gen.forIn("key", data, (key: Name) =>
|
||||
gen.if(unevaluatedDynamic(props, key), () => unevaluatedPropCode(key))
|
||||
)
|
||||
)
|
||||
} else if (props !== true) {
|
||||
gen.forIn("key", data, (key: Name) =>
|
||||
props === undefined
|
||||
? unevaluatedPropCode(key)
|
||||
: gen.if(unevaluatedStatic(props, key), () => unevaluatedPropCode(key))
|
||||
)
|
||||
}
|
||||
it.props = true
|
||||
cxt.ok(_`${errsCount} === ${N.errors}`)
|
||||
|
||||
function unevaluatedPropCode(key: Name): void {
|
||||
if (schema === false) {
|
||||
cxt.setParams({unevaluatedProperty: key})
|
||||
cxt.error()
|
||||
if (!allErrors) gen.break()
|
||||
return
|
||||
}
|
||||
|
||||
if (!alwaysValidSchema(it, schema)) {
|
||||
const valid = gen.name("valid")
|
||||
cxt.subschema(
|
||||
{
|
||||
keyword: "unevaluatedProperties",
|
||||
dataProp: key,
|
||||
dataPropType: Type.Str,
|
||||
},
|
||||
valid
|
||||
)
|
||||
if (!allErrors) gen.if(not(valid), () => gen.break())
|
||||
}
|
||||
}
|
||||
|
||||
function unevaluatedDynamic(evaluatedProps: Name, key: Name): Code {
|
||||
return _`!${evaluatedProps} || !${evaluatedProps}[${key}]`
|
||||
}
|
||||
|
||||
function unevaluatedStatic(evaluatedProps: {[K in string]?: true}, key: Name): Code {
|
||||
const ps: Code[] = []
|
||||
for (const p in evaluatedProps) {
|
||||
if (evaluatedProps[p] === true) ps.push(_`${key} !== ${p}`)
|
||||
}
|
||||
return and(...ps)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
export default def
|
||||
Loading…
Add table
Add a link
Reference in a new issue