Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sample Data for posts, posts_votes, and posts_attachments #3278

Merged
84 changes: 62 additions & 22 deletions .github/workflows/scripts/detect_ts_ignore.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import re
import sys
import logging
import os

# Configure logging
logging.basicConfig(
Expand All @@ -14,6 +15,45 @@

TS_IGNORE_PATTERN = r"(?://|/\*)\s*@ts-ignore(?:\s+|$)"

IGNORED_EXTENSIONS = {
# Image formats
".avif",
".jpeg",
".jpg",
".png",
".webp",
".gif",
".bmp",
".ico",
".svg",
# Video formats
".mp4",
".webm",
".mov",
".avi",
".mkv",
# Audio formats
".mp3",
".wav",
".ogg",
# Document formats
".pdf",
".doc",
".docx",
}


def is_binary_file(filepath: str) -> bool:
"""Check if a file is binary based on its extension.

Args:
filepath (str): The file path.

Returns:
bool: True if the file should be ignored, False otherwise.
"""
return os.path.splitext(filepath)[1].lower() in IGNORED_EXTENSIONS


def check_ts_ignore(files: list[str]) -> int:
"""Check for occurrences of '@ts-ignore' in the given files.
Expand All @@ -27,29 +67,29 @@ def check_ts_ignore(files: list[str]) -> int:
ts_ignore_found = False

for file in files:
try:
logging.info("Checking file: %s", file)
with open(file, encoding="utf-8") as f:
for line_num, line in enumerate(f, start=1):
# Handle more variations of @ts-ignore
if re.search(
TS_IGNORE_PATTERN,
line.strip(),
):
print(
"❌ Error: '@ts-ignore' found in %s at line %d",
file,
line_num,
)
logging.debug(
"Found @ts-ignore in line: %s",
if not is_binary_file(file):
try:
logging.info("Checking file: %s", file)
with open(file, encoding="utf-8") as f:
for line_num, line in enumerate(f, start=1):
# Handle more variations of @ts-ignore
if re.search(
TS_IGNORE_PATTERN,
line.strip(),
)
ts_ignore_found = True
except FileNotFoundError:
logging.warning("File not found: %s", file)
except OSError:
logging.exception("Could not read %s", file)
):
print(
f"❌ Error: '@ts-ignore' found in {file} ",
f"at line {line_num}",
)
logging.debug(
"Found @ts-ignore in line: %s",
line.strip(),
)
ts_ignore_found = True
except FileNotFoundError:
logging.warning("File not found: %s", file)
except OSError:
logging.exception("Could not read %s", file)
if not ts_ignore_found:
print("✅ No '@ts-ignore' comments found in the files.")

Expand Down
59 changes: 59 additions & 0 deletions sample_data/comment_votes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
[
{
"id": "a3990b3f-00f4-49a5-898f-ecea9de497a5",
"commentId": "14be44b7-cb4e-4d94-a115-16016674b02a",
"createdAt": "2025-02-10T12:20:00.000Z",
"creatorId": "0194e194-c6b3-7802-b074-362efea24dbc",
"type": "up_vote"
},
{
"id": "327fc011-fa70-49cf-84ab-64747a8ca4fc",
"commentId": "ac01b0f6-7bf0-4463-a3e1-95131da20bb5",
"createdAt": "2025-02-10T12:25:00.000Z",
"creatorId": "65378abd-8500-8f17-1cf2-990d00000002",
"type": "down_vote"
},
{
"id": "63c8d09c-cbc5-41fc-8e10-5bcf1c51dc74",
"commentId": "53960440-f930-4958-8bff-f7390e4f6e78",
"createdAt": "2025-02-09T10:30:00.000Z",
"creatorId": "66378abd-8500-8f17-1cf2-990d00000003",
"type": "up_vote"
},
{
"id": "303c1abb-7d96-4c24-bc60-27f3532a86ee",
"commentId": "1fe6f748-7f14-48a3-a9ba-fa4f2cd3ddbc",
"createdAt": "2025-02-09T10:35:00.000Z",
"creatorId": "67378abd-8500-8f17-1cf2-990d00000005",
"type": "down_vote"
},
{
"id": "b2007dcf-6e33-4697-add1-593623c828cd",
"commentId": "8b681992-8670-43bf-b1f8-67cd82dc4e06",
"createdAt": "2025-02-08T08:55:00.000Z",
"creatorId": "658938a6-2caa-9d8d-6908-74880000000d",
"type": "up_vote"
},
{
"id": "b74c0222-aef5-4c33-8468-1b775b6c8c56",
"commentId": "17efa258-03cf-4535-addb-2a496f4795ea",
"createdAt": "2025-02-08T09:00:00.000Z",
"creatorId": "67378abd-8500-8f17-1cf2-990d00000004",
"type": "down_vote"
},
{
"id": "b2edacc1-bf22-40b0-899f-d0791e80c7e6",
"commentId": "4fbcce27-b64b-4455-87c5-93f8e19997d2",
"createdAt": "2025-02-07T09:45:00.000Z",
"creatorId": "658938b0-2caa-9d8d-6908-74890000000e",
"type": "up_vote"
},
{
"id": "7820b237-5df6-42ea-ba7e-41d9c452d2e5",
"commentId": "ba206aeb-ffe6-49fd-8599-eac9c367bdda",
"createdAt": "2025-02-07T09:50:00.000Z",
"creatorId": "0194e194-c6b3-7802-b074-362efea24dbc",
"type": "down_vote"
}
]

59 changes: 59 additions & 0 deletions sample_data/comments.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
[
{
"id": "14be44b7-cb4e-4d94-a115-16016674b02a",
"body": "This is an insightful post!",
"createdAt": "2025-02-10T12:10:00.000Z",
"creatorId": "0194e194-c6b3-7802-b074-362efea24dbc",
"postId": "2778f4a2-a6f1-45cc-857f-727ca942899d"
},
{
"id": "ac01b0f6-7bf0-4463-a3e1-95131da20bb5",
"body": "Great initiative! Looking forward to more updates.",
"createdAt": "2025-02-10T12:15:00.000Z",
"creatorId": "65378abd-8500-8f17-1cf2-990d00000002",
"postId": "98cef234-af91-4a11-b33f-5fd6cf41219c"
},
{
"id": "53960440-f930-4958-8bff-f7390e4f6e78",
"body": "This bootcamp will help a lot of people!",
"createdAt": "2025-02-09T10:20:00.000Z",
"creatorId": "66378abd-8500-8f17-1cf2-990d00000003",
"postId": "a44d75a0-267f-4429-b03c-a26cc4ec56dc"
},
{
"id": "1fe6f748-7f14-48a3-a9ba-fa4f2cd3ddbc",
"body": "Well organized event! Keep up the good work.",
"createdAt": "2025-02-09T10:25:00.000Z",
"creatorId": "67378abd-8500-8f17-1cf2-990d00000005",
"postId": "f3da248b-ee18-4197-bd0b-de5480c010ee"
},
{
"id": "8b681992-8670-43bf-b1f8-67cd82dc4e06",
"body": "Providing free legal aid is crucial!",
"createdAt": "2025-02-08T08:50:00.000Z",
"creatorId": "658938a6-2caa-9d8d-6908-74880000000d",
"postId": "885bee36-2751-4d78-bfd4-7ededdd89a0f"
},
{
"id": "17efa258-03cf-4535-addb-2a496f4795ea",
"body": "Access to justice for all is a fundamental right!",
"createdAt": "2025-02-08T08:55:00.000Z",
"creatorId": "67378abd-8500-8f17-1cf2-990d00000004",
"postId": "ecaeed44-d0b2-4559-bad6-ab6f49362325"
},
{
"id": "4fbcce27-b64b-4455-87c5-93f8e19997d2",
"body": "Senior wellness programs are essential!",
"createdAt": "2025-02-07T09:35:00.000Z",
"creatorId": "658938b0-2caa-9d8d-6908-74890000000e",
"postId": "2022fe3e-846e-48de-8a27-230fda85e495"
},
{
"id": "ba206aeb-ffe6-49fd-8599-eac9c367bdda",
"body": "Such programs help maintain mental and physical health.",
"createdAt": "2025-02-07T09:40:00.000Z",
"creatorId": "0194e194-c6b3-7802-b074-362efea24dbc",
"postId": "17f0e29a-f7a2-435e-8dc1-2e52c6b25b6c"
}
]

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 51 additions & 0 deletions sample_data/post_attachments.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[
{
"id": "8a0aff46-6f59-4626-9005-6528fdcab7e8",
"createdAt": "2025-02-10T12:10:00.000Z",
"creatorId": "0194e194-c6b3-7802-b074-362efea24dbc",
"postId": "2778f4a2-a6f1-45cc-857f-727ca942899d",
"mimeType": "image/jpeg",
"name": "01JMQ3EABXAD1F3KTW1NQGF99C"
},
{
"id": "e1bba4bb-5edd-40fd-9baf-741647d26ec0",
"createdAt": "2025-02-10T12:11:00.000Z",
"creatorId": "0194e194-c6b3-7802-b074-362efea24dbc",
"postId": "98cef234-af91-4a11-b33f-5fd6cf41219c",
"mimeType": "image/webp",
"name": "01JMQ3ETE4Q257BJV59TBSNJMN"
},
{
"id": "5065ab3d-51bd-4c6e-b3e3-389af5610cc3",
"createdAt": "2025-02-10T12:20:00.000Z",
"creatorId": "65378abd-8500-8f17-1cf2-990d00000002",
"postId": "a44d75a0-267f-4429-b03c-a26cc4ec56dc",
"mimeType": "image/jpeg",
"name": "01JMQ3F1B55K272B25V19781D0"
},
{
"id": "ea15240d-269d-4c94-8f7c-fa4723bd3413",
"createdAt": "2025-02-10T12:21:00.000Z",
"creatorId": "65378abd-8500-8f17-1cf2-990d00000002",
"postId": "f3da248b-ee18-4197-bd0b-de5480c010ee",
"mimeType": "image/jpeg",
"name": "01JMQ3F9E5C806CN6M8EV31E01"
},
{
"id": "c898e282-29e4-4f0c-abb3-0829c6091575",
"createdAt": "2025-02-10T12:30:00.000Z",
"creatorId": "67378abd-8500-8f17-1cf2-990d00000005",
"postId": "885bee36-2751-4d78-bfd4-7ededdd89a0f",
"mimeType": "image/jpeg",
"name": "01JMQ3FGBEDRB9AM6XP9C97RF8"
},
{
"id": "685b4d55-9627-474d-a8d8-d36aaf34a93d",
"createdAt": "2025-02-10T12:31:00.000Z",
"creatorId": "67378abd-8500-8f17-1cf2-990d00000005",
"postId": "ecaeed44-d0b2-4559-bad6-ab6f49362325",
"mimeType": "image/jpeg",
"name": "01JMQ3FPS789Z1J6BBQ01YDHVQ"
}
]

59 changes: 59 additions & 0 deletions sample_data/post_votes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
[
{
"id": "8e3bae34-955b-4f55-9118-e03e56c5faeb",
"createdAt": "2025-02-12T14:10:00.000Z",
"creatorId": "0194e194-c6b3-7802-b074-362efea24dbc",
"postId": "2778f4a2-a6f1-45cc-857f-727ca942899d",
"type": "up_vote"
},
{
"id": "abe50392-5b74-4edc-a933-7e98f1106999",
"createdAt": "2025-02-12T14:12:00.000Z",
"creatorId": "65378abd-8500-8f17-1cf2-990d00000002",
"postId": "98cef234-af91-4a11-b33f-5fd6cf41219c",
"type": "down_vote"
},
{
"id": "7491184e-d12a-4d19-a955-78a08b2fa058",
"createdAt": "2025-02-13T10:30:00.000Z",
"creatorId": "67378abd-8500-8f17-1cf2-990d00000005",
"postId": "a44d75a0-267f-4429-b03c-a26cc4ec56dc",
"type": "up_vote"
},
{
"id": "cca57ea7-2c98-4bb7-8d76-a01a8bfbfaf4",
"createdAt": "2025-02-13T10:35:00.000Z",
"creatorId": "0194e194-c6b3-7802-b074-362efea24dbc",
"postId": "f3da248b-ee18-4197-bd0b-de5480c010ee",
"type": "down_vote"
},
{
"id": "f5644877-31a8-443f-bd21-c79269c9f859",
"createdAt": "2025-02-14T08:45:00.000Z",
"creatorId": "67378abd-8500-8f17-1cf2-990d00000006",
"postId": "885bee36-2751-4d78-bfd4-7ededdd89a0f",
"type": "up_vote"
},
{
"id": "da8e8ab7-3521-4596-992d-c2de4e60bb71",
"createdAt": "2025-02-14T08:50:00.000Z",
"creatorId": "66378abd-8500-8f17-1cf2-990d00000003",
"postId": "ecaeed44-d0b2-4559-bad6-ab6f49362325",
"type": "down_vote"
},
{
"id": "2ca3cced-6dfc-4f66-b79e-c18b4477080e",
"createdAt": "2025-02-15T09:30:00.000Z",
"creatorId": "658938a6-2caa-9d8d-6908-74880000000d",
"postId": "d3288d60-11c7-4401-ac70-f36f289c385f",
"type": "up_vote"
},
{
"id": "29c8d791-8aac-4a73-a16c-84696366d42e",
"createdAt": "2025-02-15T09:35:00.000Z",
"creatorId": "67378abd-8500-8f17-1cf2-990d00000007",
"postId": "2022fe3e-846e-48de-8a27-230fda85e495",
"type": "down_vote"
}
]

Loading
Loading