MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / get_push_papers

Function get_push_papers

skills/storage-helper/scripts/db_ops.py:1772–1836  ·  view source on GitHub ↗

Get all papers for a specific push ID Args: push_id: Push ID Returns: Push information with papers list

(push_id: str)

Source from the content-addressed store, hash-verified

1770
1771
1772def get_push_papers(push_id: str) -> Optional[Dict]:
1773 """
1774 Get all papers for a specific push ID
1775
1776 Args:
1777 push_id: Push ID
1778
1779 Returns:
1780 Push information with papers list
1781 """
1782 conn = get_connection()
1783 cursor = conn.cursor()
1784
1785 # Get push time
1786 cursor.execute("""
1787 SELECT DISTINCT push_id, timestamp
1788 FROM behavior_logs
1789 WHERE push_id = ?
1790 ORDER BY timestamp ASC
1791 LIMIT 1
1792 """, (push_id,))
1793
1794 row = cursor.fetchone()
1795 if not row:
1796 conn.close()
1797 return None
1798
1799 push_time = row['timestamp']
1800
1801 # Get all papers in this push with metadata.
1802 cursor.execute("""
1803 SELECT p.*, bl.id as behavior_log_id, bl.metadata
1804 FROM papers p
1805 JOIN behavior_logs bl ON p.id = bl.paper_id
1806 WHERE bl.push_id = ? AND bl.action = 'pushed'
1807 ORDER BY bl.id ASC
1808 """, (push_id,))
1809
1810 papers = [_build_paper_dict(row) for row in cursor.fetchall()]
1811 papers.sort(key=lambda paper: (paper.get("rank", 10**9), paper.get("behavior_log_id", 10**9)))
1812
1813 cursor.execute(
1814 """
1815 SELECT metadata
1816 FROM behavior_logs
1817 WHERE push_id = ?
1818 AND action = 'push_empty'
1819 ORDER BY id DESC
1820 LIMIT 1
1821 """,
1822 (push_id,),
1823 )
1824 metadata_row = cursor.fetchone()
1825 push_metadata = _load_json_metadata(metadata_row["metadata"]) if metadata_row else {}
1826 if not push_metadata:
1827 push_metadata = _derive_push_metadata_from_papers(papers)
1828
1829 conn.close()

Calls 9

_build_paper_dictFunction · 0.85
_load_json_metadataFunction · 0.85
cursorMethod · 0.80
getMethod · 0.80
get_connectionFunction · 0.70
executeMethod · 0.45
closeMethod · 0.45
fetchallMethod · 0.45