Page MenuHomePhabricator

D14145.id46371.diff
No OneTemporary

D14145.id46371.diff

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

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)

Event Timeline