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

Convert mailer_emoji JSON file to map #725

Conversation

adamantike
Copy link
Contributor

@adamantike adamantike commented May 13, 2023

This fixes a pending TODO comment regarding inefficient tags to emojis mapping, by requiring a full scan over emoji aliases to determine matches.

Instead, now the JSON file is a map, with aliases as keys, and emojis as values. The script to convert the file with Python was:

import json

with open("./server/mailer_emoji.json", "r", encoding="utf-8") as f:
    content = json.load(f)

emoji_map = {}
for emoji in content:
    for alias in emoji["aliases"]:
        if alias in emoji_map:
            print("WARNING: Duplicate alias:", alias)
            continue
        emoji_map[alias] = emoji["emoji"]

sorted_emoji_map = {k: emoji_map[k] for k in sorted(emoji_map)}

with open("./server/mailer_emoji_map.json", "w", encoding="utf-8") as f:
    json.dump(sorted_emoji_map, f, indent=4, ensure_ascii=False)

This fixes a pending TODO comment regarding inefficient tags to emojis
mapping, by requiring a full scan over emoji aliases to determine
matches.

Instead, now the JSON file is a map, with aliases as keys, and emojis as
values. The script to convert the file with Python was:

```python
import json

with open("./mailer_emoji.json", "r", encoding="utf-8") as f:
    content = json.load(f)

emoji_map = {}
for emoji in content:
    for alias in emoji["aliases"]:
        if alias in emoji_map:
            print("WARNING: Duplicate alias:", alias)
            continue
        emoji_map[alias] = str(emoji["emoji"])

sorted_emoji_map = {k: emoji_map[k] for k in sorted(emoji_map)}

with open("./mailer_emoji_map.json", "w", encoding="utf-8") as f:
    json.dump(sorted_emoji_map, f, indent=4, ensure_ascii=False)
```
@adamantike adamantike force-pushed the misc/migrate-mailer-emoji-json-to-map branch from 0acf910 to 49bd612 Compare May 13, 2023 14:44
@codecov-commenter
Copy link

Codecov Report

Patch coverage: 85.71% and project coverage change: +0.01 🎉

Comparison is base (bd81aef) 66.34% compared to head (49bd612) 66.36%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #725      +/-   ##
==========================================
+ Coverage   66.34%   66.36%   +0.01%     
==========================================
  Files          48       48              
  Lines        6873     6871       -2     
==========================================
  Hits         4560     4560              
+ Misses       1601     1600       -1     
+ Partials      712      711       -1     
Impacted Files Coverage Δ
server/smtp_sender.go 52.74% <85.71%> (-1.02%) ⬇️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@binwiederhier
Copy link
Owner

Thanks

@binwiederhier binwiederhier merged commit 5b7c500 into binwiederhier:main May 14, 2023
2 checks passed
@adamantike adamantike deleted the misc/migrate-mailer-emoji-json-to-map branch May 14, 2023 19:32
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.

None yet

3 participants