Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache additional routes: people/by-year and people/by-name #471

Merged
merged 1 commit into from
Jan 22, 2025

Conversation

line-o
Copy link
Contributor

@line-o line-o commented Jan 20, 2025

@line-o line-o requested review from joewiz and windauer and removed request for joewiz January 20, 2025 13:04
modules/config.xqm Outdated Show resolved Hide resolved
modules/config.xqm Outdated Show resolved Hide resolved
@line-o
Copy link
Contributor Author

line-o commented Jan 22, 2025

@joewiz I just did a small test in docker and all three implementations of the function did perform equally well:

That means we can choose the one that is most readable to us. As I prefer the first one and I think you do too this is the one I changed it to.

declare variable $local:POCOM_PEOPLE_COL := '/db/apps/pocom/people';

declare function local:pocom-people-last-modified() as xs:dateTime {
    collection($local:POCOM_PEOPLE_COL)//last-modified-date
    => sort() => reverse() => head() => concat("T00:00:00Z") => xs:dateTime()
};

declare function local:pocom-people-last-modified-2() as xs:dateTime {
    xs:dateTime(concat(
        head(reverse(sort(collection($local:POCOM_PEOPLE_COL)//last-modified-date))) ,"T00:00:00Z"))
};

declare function local:pocom-people-last-modified-3() as xs:dateTime {
    head(
        for $raw-date in collection($local:POCOM_PEOPLE_COL)//last-modified-date
        let $date := xs:dateTime($raw-date || "T00:00:00Z")
        order by $date descending
        return $date
    )
};

local:pocom-people-last-modified-2()

@line-o line-o requested a review from joewiz January 22, 2025 13:10
Use the last-modified-date metadatum in the relevant collection to calculate
the collection wide last modified date.
@line-o line-o force-pushed the feat/people-caching branch from 090b1d6 to d3e0fca Compare January 22, 2025 13:13
@joewiz
Copy link
Member

joewiz commented Jan 22, 2025

@line-o Great! In that case, I agree that the 1st option is the most readable. Thank you!

@windauer windauer merged commit cf17eaa into HistoryAtState:master Jan 22, 2025
3 checks passed
Copy link

🎉 This PR is included in version 3.7.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants