Skip to content

Auto-translated map_item updates from 4CAT: twitter-import - #102

Draft
4cat-to-zeeschuimer-automation-pr[bot] wants to merge 1 commit into
masterfrom
auto/4cat-map-item-sync-twitter-import
Draft

4cat-to-zeeschuimer-automation-pr[bot] wants to merge 1 commit into
masterfrom
auto/4cat-map-item-sync-twitter-import

Conversation

@4cat-to-zeeschuimer-automation-pr

Copy link
Copy Markdown
Contributor

🤖 This PR was auto-generated by the 4CAT map_item sync workflow. The JavaScript was produced by an LLM and requires human review before merging — including manual fixes for any lint warnings flagged below.

Generation parameters

  • Model: gpt-oss-120b (provider: litellm)
  • Total LLM time: 48.65s
  • Trigger: push of 7cba15f to 4CAT master (module: twitter-import).

Summary

  • ✅ 1 translated
  • ⚠️ 1 translated with lint warnings (require manual fix)
  • ❌ 0 failed
  • ❔ 0 skipped
Datasource Module Time Warnings
datasources/twitter-import/search_twitter.py modules/twitter.js 48.63s ⚠️ 3

⚠️ Lint warnings — fix before merging

The following datasources translated successfully but the static lint flagged issues that need human fixes. The auto-generated code was spliced into the JS module as-is; please patch the file directly in this PR.

datasources/twitter-import/search_twitter.py -> modules/twitter.js

  • [helpers_to_add[5]] Bare truthy check on a name that looks like a collection. An empty [] or {} is false in Python and true in JavaScript, so this takes the opposite branch on an empty list, and the code inside then indexes element [0] of it. Use Array.isArray(x) && x.length (or Object.keys(x).length). NOTE: the check goes by the name, so a plural holding a string or a boolean is a false positive — ignore the warning if the value is not a list or an object.
  • [helpers_to_add[7]] Regex detected. The current LLM translates regex unreliably (escapes, character classes, flags) — please verify the regex behavior against the Python original by hand.
  • [helpers_to_add[9]] .toFixed( found. It pads with zeros where Python's str(round(x, n)) does not, turning a coordinate like 4.85 into 4.850000. NOTE: the corrected form String(Number(x.toFixed(n))) contains .toFixed( as well — ignore the warning where the result is already wrapped in Number(.

datasources/twitter-import/search_twitter.py -> modules/twitter.js (48.63s) ⚠️

LLM commentary:

Implemented map_item to dispatch between modern and legacy tweet shapes using py_get for safe dict access. All helper static methods from the Python class are provided as top‑level functions: map_user, get_note_result, get_full_text, get_entities, get_media, _screen_name_from_url, _screen_name_from_media, and get_centroid. Date parsing uses the built‑in Date constructor; formatUtcTimestamp formats the Unix timestamp. All Python truthy fallbacks (or) are translated to JavaScript ||, and dict.get calls become py_get. Missing fields are left as empty strings to match the original Python output. No external imports are required beyond the global helpers supplied by Zeeschuimer.

Python diff
diff --git a/datasources/twitter-import/search_twitter.py b/datasources/twitter-import/search_twitter.py
index 213770e1..79c24e51 100644
--- a/datasources/twitter-import/search_twitter.py
+++ b/datasources/twitter-import/search_twitter.py
@@ -153,7 +153,7 @@ class SearchTwitterViaZeeschuimer(Search):
             "author_bio": author_bio,
             "author_location": author_location,
             "verified": author_verified,
-            "source": strip_tags(tweet["source"]),
+            "source": strip_tags(tweet.get("source", "")),
             "language_guess": tweet["legacy"].get("lang"),
             "possibly_sensitive": "yes" if tweet.get("possibly_sensitive", False) or tweet["legacy"].get("possibly_sensitive", False) else "no",
             "retweet_count": tweet["legacy"]["retweet_count"],

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.

1 participant