Skip to content

Order Feeds by Date not Cache File#17

Open
Ipstenu wants to merge 2 commits intomainfrom
attempting-reconnect
Open

Order Feeds by Date not Cache File#17
Ipstenu wants to merge 2 commits intomainfrom
attempting-reconnect

Conversation

@Ipstenu
Copy link
Contributor

@Ipstenu Ipstenu commented Jan 29, 2026

Issue

Feeds are showing out of order. This is because the planet is ordered by when the cache file was last written (file mtime), not by when the post was published. So:

  • April 14, 2025 (OpenChannels.fm) appears first because its cache file has a newer mtime (e.g. that feed was spidered more recently, or its filename sorts first when mtimes are equal).
  • Jan 29, 2026 appears second even though it’s newer, because its cache file is older on disk or sorts later.
    Relevant code:

splice never looks at the entry’s date; it only uses file mtime and path.

Summary of Changes

1. Helper _entry_date_sort_key(filepath) (venus/planet/splice.py)

  • Parses each cache file as Atom XML.
  • Uses the entry’s <updated> or <published> (Atom NS) and parses it with feedparser._parse_date_iso8601().
  • Returns a 9-tuple time for sorting; on parse error or missing date, returns time.gmtime(os.stat(filepath).st_mtime).

2. Sort by entry date (newest first) (venus/planet/splice.py)

  • Replaced the old logic that built dir from (os.stat(file).st_mtime, file) and reversed it.
  • Now builds dir by calling _entry_date_sort_key(file) for each cache file and appending (sort_key, file).
  • Sorts with dir.sort(key=lambda x: x[0], reverse=True) so newest entry date is first.
  • The loop that adds entries is unchanged; it still respects new_feed_items, max_items, sub_ids, and idindex. Only the order of iteration over cache files changed.

3. Shared atomNS

  • atomNS = 'http://www.w3.org/2005/Atom' is defined at module level and used by the helper and the existing getElementsByTagNameNS(atomNS, 'source') in the loop.

Result

The planet page is ordered by the entry’s published/updated date (newest first), so Jan 29, 2026 will appear before April 14, 2025 when you rebuild. Tests were not run in this environment (Python 2 / venv expectations), but the change only affects sort order, not which entries are included, so the existing count assertions (12, 8, 9 entries) should still hold.

…ontent and improving formatting. Cleaned up unnecessary sections and ensured consistency in comments.

Signed-off-by: Mika Ipstenu Epstein <ipstenu@halfelf.org>
Currently planet feed is ordered by when the CACHE file was last written (file mtime), not by when the post was published. Meaning any new feeds listed would be showing as newer.

To fix this, I have updated  venus/planet/splice.py, build the list of entries to include by getting the Atom XML updated or published data and sorting by that first.

This will still respect new_feed_items, max_items, sub_ids, and idindex; only the order in which cache files are considered changes.

Signed-off-by: Mika Ipstenu Epstein <ipstenu@halfelf.org>
@Ipstenu Ipstenu linked an issue Jan 29, 2026 that may be closed by this pull request
@Ipstenu Ipstenu requested a review from rmccue January 29, 2026 22:12
@Ipstenu Ipstenu changed the title Attempting reconnect Order Feeds by Date not Cache File Jan 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove 'powered by' link and Planetarium

1 participant