MCPcopy Index your code
hub / github.com/vastsa/FileCodeBox / _build_file_timeline

Method _build_file_timeline

apps/admin/services.py:1195–1285  ·  view source on GitHub ↗
(
        self,
        file_code: FileCodes,
        detail: dict[str, Any],
        now: datetime,
        has_download_limit: bool,
        is_permanent: bool,
        is_text: bool,
    )

Source from the content-addressed store, hash-verified

1193 }
1194
1195 def _build_file_timeline(
1196 self,
1197 file_code: FileCodes,
1198 detail: dict[str, Any],
1199 now: datetime,
1200 has_download_limit: bool,
1201 is_permanent: bool,
1202 is_text: bool,
1203 ) -> list[dict[str, Any]]:
1204 remaining_downloads = detail["remainingDownloads"]
1205 seconds_until_expiration = self._seconds_between(now, file_code.expired_at)
1206 timeline = [
1207 {
1208 "key": "created",
1209 "status": "done",
1210 "severity": "success",
1211 "timestamp": file_code.created_at,
1212 },
1213 {
1214 "key": "content_ready",
1215 "status": "done",
1216 "severity": "success",
1217 "timestamp": file_code.created_at,
1218 "detail": "text" if is_text else "file",
1219 },
1220 ]
1221
1222 if file_code.upload_id:
1223 timeline.append(
1224 {
1225 "key": "upload_session",
1226 "status": "done",
1227 "severity": "info",
1228 "timestamp": file_code.created_at,
1229 "detail": file_code.upload_id,
1230 }
1231 )
1232
1233 if is_permanent:
1234 timeline.append(
1235 {
1236 "key": "expiration_policy",
1237 "status": "unlimited",
1238 "severity": "success",
1239 "timestamp": None,
1240 }
1241 )
1242 elif file_code.expired_at is not None:
1243 expired = seconds_until_expiration is not None and seconds_until_expiration <= 0
1244 timeline.append(
1245 {
1246 "key": "expiration_policy",
1247 "status": "expired" if expired else "pending",
1248 "severity": "danger" if expired else "warning",
1249 "timestamp": file_code.expired_at,
1250 "value": seconds_until_expiration,
1251 }
1252 )

Callers 1

get_file_detailMethod · 0.95

Calls 1

_seconds_betweenMethod · 0.95

Tested by

no test coverage detected