ajit3259 commited on
Commit
df58f94
·
1 Parent(s): 7dcfe8c

fix: pin new capture to top of Just Added feed regardless of server clock skew

Browse files
Files changed (4) hide show
  1. app.py +9 -0
  2. db.py +14 -0
  3. static/_app/index-C37B1Xuh.js +0 -0
  4. static/index.html +1 -1
app.py CHANGED
@@ -157,6 +157,15 @@ async def list_captures(limit: int = 50, intent: Optional[str] = None):
157
  return get_captures_by_intent(intent, limit)
158
  return get_captures(limit)
159
 
 
 
 
 
 
 
 
 
 
160
  @app.get("/captures/{capture_id}/related")
161
  async def related_captures(capture_id: int):
162
  import sqlite3
 
157
  return get_captures_by_intent(intent, limit)
158
  return get_captures(limit)
159
 
160
+ @app.get("/captures/{capture_id}")
161
+ async def get_capture(capture_id: int):
162
+ from db import get_capture_by_id
163
+ c = get_capture_by_id(capture_id)
164
+ if not c:
165
+ raise HTTPException(status_code=404)
166
+ return c
167
+
168
+
169
  @app.get("/captures/{capture_id}/related")
170
  async def related_captures(capture_id: int):
171
  import sqlite3
db.py CHANGED
@@ -135,6 +135,20 @@ def get_captures_by_intent(intent: str, limit=50):
135
  return result
136
 
137
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
  def get_captures(limit=50):
139
  with sqlite3.connect(DB_PATH) as conn:
140
  conn.row_factory = sqlite3.Row
 
135
  return result
136
 
137
 
138
+ def get_capture_by_id(capture_id: int):
139
+ with sqlite3.connect(DB_PATH) as conn:
140
+ conn.row_factory = sqlite3.Row
141
+ row = conn.execute("SELECT * FROM captures WHERE id=?", (capture_id,)).fetchone()
142
+ if not row:
143
+ return None
144
+ d = dict(row)
145
+ d["tags"] = json.loads(d["tags"] or "[]")
146
+ d["related_ids"] = json.loads(d.get("related_ids") or "[]")
147
+ d["claims"] = json.loads(d.get("claims") or "[]")
148
+ d.pop("embedding", None)
149
+ return d
150
+
151
+
152
  def get_captures(limit=50):
153
  with sqlite3.connect(DB_PATH) as conn:
154
  conn.row_factory = sqlite3.Row
static/_app/index-C37B1Xuh.js ADDED
The diff for this file is too large to render. See raw diff
 
static/index.html CHANGED
@@ -5,7 +5,7 @@
5
  <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
  <title>Mycelium</title>
8
- <script type="module" crossorigin src="/_app/index-Dx9Oo2J9.js"></script>
9
  <link rel="stylesheet" crossorigin href="/_app/index-BvUgL4Tz.css">
10
  </head>
11
  <body>
 
5
  <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
  <title>Mycelium</title>
8
+ <script type="module" crossorigin src="/_app/index-C37B1Xuh.js"></script>
9
  <link rel="stylesheet" crossorigin href="/_app/index-BvUgL4Tz.css">
10
  </head>
11
  <body>