Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3513152
D14145.id46371.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D14145.id46371.diff
View Options
diff --git a/keyserver/src/scripts/get-community-ids.js b/keyserver/src/scripts/get-community-ids.js
new file mode 100644
--- /dev/null
+++ b/keyserver/src/scripts/get-community-ids.js
@@ -0,0 +1,34 @@
+// @flow
+
+import { main } from './utils.js';
+import { dbQuery, SQL } from '../database/database.js';
+
+async function fetchCommunityIDsByNames(
+ communityNames: $ReadOnlyArray<string>,
+): Promise<$ReadOnlyArray<string>> {
+ if (communityNames.length === 0) {
+ return [];
+ }
+
+ const query = SQL`
+ SELECT c.id
+ FROM communities c
+ INNER JOIN threads t
+ ON c.id = t.id
+ WHERE t.name IN (${communityNames})
+ `;
+
+ const [result] = await dbQuery(query);
+
+ const communityIDs = result.map(row => row.id.toString());
+
+ return communityIDs;
+}
+
+async function fetchCommunityIDsByNamesScript() {
+ const communityNames: $ReadOnlyArray<string> = []; // Replace with actual community names
+ const communityIDs = await fetchCommunityIDsByNames(communityNames);
+ console.log('Fetched Community IDs:', communityIDs);
+}
+
+main([fetchCommunityIDsByNamesScript]);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 22, 10:55 PM (4 h, 41 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2692784
Default Alt Text
D14145.id46371.diff (1 KB)
Attached To
Mode
D14145: [keyserver][script] get IDs for community names
Attached
Detach File
Event Timeline
Log In to Comment