MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / clearCache

Function clearCache

admin/src/commands/clear-cache.ts:22–162  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

20}
21
22export async function clearCache() {
23 console.log(chalk.blue('\n🗑️ Clear Cache\n'));
24 console.log('Loading organizations...\n');
25
26 const organizations = await db.organization.findMany({
27 orderBy: {
28 name: 'asc',
29 },
30 });
31
32 if (organizations.length === 0) {
33 console.log(chalk.red('No organizations found.'));
34 return;
35 }
36
37 const searchItems: OrgSearchItem[] = organizations.map((org) => ({
38 id: org.id,
39 name: org.name,
40 displayText: `${org.name} ${chalk.gray(`(${org.id})`)}`,
41 }));
42
43 const searchFunction = async (_answers: unknown, input = '') => {
44 const fuzzyResult = fuzzy.filter(input, searchItems, {
45 extract: (item: OrgSearchItem) => `${item.name} ${item.id}`,
46 });
47
48 return fuzzyResult.map((result: fuzzy.FilterResult<OrgSearchItem>) => ({
49 name: result.original.displayText,
50 value: result.original,
51 }));
52 };
53
54 const { selectedOrg } = (await inquirer.prompt([
55 {
56 type: 'autocomplete',
57 name: 'selectedOrg',
58 message: 'Search for an organization:',
59 source: searchFunction,
60 pageSize: 15,
61 },
62 ])) as { selectedOrg: OrgSearchItem };
63
64 // Fetch organization with all projects
65 const organization = await db.organization.findUnique({
66 where: {
67 id: selectedOrg.id,
68 },
69 include: {
70 projects: {
71 orderBy: {
72 name: 'asc',
73 },
74 },
75 members: {
76 include: {
77 user: true,
78 },
79 },

Callers 1

mainFunction · 0.90

Calls 4

joinMethod · 0.80
logMethod · 0.45
mapMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected