search for standard sites pub-search.waow.tech
search zig blog atproto
11
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: generate embedded_at timestamp in zig, not strftime

strftime in parameterized turso pipeline queries may not evaluate
as expected. generate the ISO timestamp in zig and pass as arg.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

zzstoatzz 3354cf1f 86db334f

+16 -3
+16 -3
backend/src/ingest/embedder.zig
··· 165 165 return error.TpufUpsertFailed; 166 166 }; 167 167 168 - // mark docs as embedded in turso (one exec per doc — simpler than batch) 168 + // mark docs as embedded in turso 169 + // generate timestamp in Zig (avoids any strftime/pipeline API quirks) 170 + const now_ts = std.time.timestamp(); 171 + const epoch_secs: u64 = @intCast(now_ts); 172 + const epoch = std.time.epoch.EpochSeconds{ .secs = epoch_secs }; 173 + const day = epoch.getDaySeconds(); 174 + const yd = epoch.getEpochDay().calculateYearDay(); 175 + const md = yd.calculateMonthDay(); 176 + var ts_buf: [20]u8 = undefined; 177 + const ts = std.fmt.bufPrint(&ts_buf, "{d:0>4}-{d:0>2}-{d:0>2}T{d:0>2}:{d:0>2}:{d:0>2}", .{ 178 + yd.year, md.month.numeric(), @as(u32, md.day_index) + 1, 179 + day.getHoursIntoDay(), day.getMinutesIntoHour(), day.getSecondsIntoMinute(), 180 + }) catch "1970-01-01T00:00:00"; 181 + 169 182 for (docs.items) |doc| { 170 183 client.exec( 171 - "UPDATE documents SET embedded_at = strftime('%Y-%m-%dT%H:%M:%S', 'now') WHERE uri = ?", 172 - &.{doc.uri}, 184 + "UPDATE documents SET embedded_at = ? WHERE uri = ?", 185 + &.{ ts, doc.uri }, 173 186 ) catch |err| { 174 187 logfire.warn("embedder: failed to mark {s}: {}", .{ doc.uri, err }); 175 188 };