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>
72 lines
1.8 KiB
JavaScript
72 lines
1.8 KiB
JavaScript
/**
|
|
* @fileoverview Defines a storage for rules.
|
|
* @author Nicholas C. Zakas
|
|
* @author aladdin-add
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
//------------------------------------------------------------------------------
|
|
// Requirements
|
|
//------------------------------------------------------------------------------
|
|
|
|
const builtInRules = require("../rules");
|
|
|
|
//------------------------------------------------------------------------------
|
|
// Typedefs
|
|
//------------------------------------------------------------------------------
|
|
|
|
/** @typedef {import("../shared/types").Rule} Rule */
|
|
|
|
//------------------------------------------------------------------------------
|
|
// Public Interface
|
|
//------------------------------------------------------------------------------
|
|
|
|
/**
|
|
* A storage for rules.
|
|
*/
|
|
class Rules {
|
|
constructor() {
|
|
this._rules = Object.create(null);
|
|
}
|
|
|
|
/**
|
|
* Registers a rule module for rule id in storage.
|
|
* @param {string} ruleId Rule id (file name).
|
|
* @param {Rule} rule Rule object.
|
|
* @returns {void}
|
|
*/
|
|
define(ruleId, rule) {
|
|
this._rules[ruleId] = rule;
|
|
}
|
|
|
|
/**
|
|
* Access rule handler by id (file name).
|
|
* @param {string} ruleId Rule id (file name).
|
|
* @returns {Rule} Rule object.
|
|
*/
|
|
get(ruleId) {
|
|
if (typeof this._rules[ruleId] === "string") {
|
|
this.define(ruleId, require(this._rules[ruleId]));
|
|
}
|
|
if (this._rules[ruleId]) {
|
|
return this._rules[ruleId];
|
|
}
|
|
if (builtInRules.has(ruleId)) {
|
|
return builtInRules.get(ruleId);
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
*[Symbol.iterator]() {
|
|
yield* builtInRules;
|
|
|
|
for (const ruleId of Object.keys(this._rules)) {
|
|
yield [ruleId, this.get(ruleId)];
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = Rules;
|