|
| 1 | +// Fake data generators |
| 2 | +const firstNames = [ |
| 3 | + "Alex", |
| 4 | + "Jordan", |
| 5 | + "Taylor", |
| 6 | + "Morgan", |
| 7 | + "Casey", |
| 8 | + "Riley", |
| 9 | + "Avery", |
| 10 | + "Quinn", |
| 11 | + "Emma", |
| 12 | + "Liam", |
| 13 | + "Olivia", |
| 14 | + "Noah", |
| 15 | + "Ava", |
| 16 | + "Ethan", |
| 17 | + "Sophia", |
| 18 | + "Mason", |
| 19 | + "Isabella", |
| 20 | + "William", |
| 21 | + "Mia", |
| 22 | + "James", |
| 23 | + "Charlotte", |
| 24 | + "Benjamin", |
| 25 | + "Amelia", |
| 26 | + "Lucas", |
| 27 | + "Harper", |
| 28 | + "Henry", |
| 29 | + "Evelyn", |
| 30 | + "Alexander", |
| 31 | + "Abigail", |
| 32 | + "Michael", |
| 33 | + "Emily", |
| 34 | + "Daniel", |
| 35 | + "Elizabeth", |
| 36 | + "Jacob", |
| 37 | + "Sofia", |
| 38 | + "Logan", |
| 39 | + "Avery", |
| 40 | + "Jackson", |
| 41 | + "Ella", |
| 42 | + "Sebastian", |
| 43 | +]; |
| 44 | + |
| 45 | +const lastNames = [ |
| 46 | + "Smith", |
| 47 | + "Johnson", |
| 48 | + "Williams", |
| 49 | + "Brown", |
| 50 | + "Jones", |
| 51 | + "Garcia", |
| 52 | + "Miller", |
| 53 | + "Davis", |
| 54 | + "Rodriguez", |
| 55 | + "Martinez", |
| 56 | + "Hernandez", |
| 57 | + "Lopez", |
| 58 | + "Gonzalez", |
| 59 | + "Wilson", |
| 60 | + "Anderson", |
| 61 | + "Thomas", |
| 62 | + "Taylor", |
| 63 | + "Moore", |
| 64 | + "Jackson", |
| 65 | + "Martin", |
| 66 | + "Lee", |
| 67 | + "Perez", |
| 68 | + "Thompson", |
| 69 | + "White", |
| 70 | + "Harris", |
| 71 | + "Sanchez", |
| 72 | + "Clark", |
| 73 | + "Ramirez", |
| 74 | + "Lewis", |
| 75 | + "Robinson", |
| 76 | + "Walker", |
| 77 | + "Young", |
| 78 | + "Allen", |
| 79 | + "King", |
| 80 | + "Wright", |
| 81 | + "Scott", |
| 82 | + "Torres", |
| 83 | + "Nguyen", |
| 84 | + "Hill", |
| 85 | + "Flores", |
| 86 | +]; |
| 87 | + |
| 88 | +const actions = [ |
| 89 | + "created a new project", |
| 90 | + "deleted a file", |
| 91 | + "shared a document", |
| 92 | + "commented on a task", |
| 93 | + "completed a milestone", |
| 94 | + "invited a team member", |
| 95 | + "updated project settings", |
| 96 | + "exported data report", |
| 97 | + "created a new team", |
| 98 | + "archived old project", |
| 99 | + "updated billing information", |
| 100 | + "changed password", |
| 101 | + "enabled two-factor authentication", |
| 102 | + "uploaded a new file", |
| 103 | + "created a backup", |
| 104 | + "merged a pull request", |
| 105 | + "deployed to production", |
| 106 | + "ran automated tests", |
| 107 | + "reviewed code changes", |
| 108 | + "created a new API key", |
| 109 | + "updated integration settings", |
| 110 | + "scheduled a meeting", |
| 111 | + "published a blog post", |
| 112 | + "updated documentation", |
| 113 | + "created a new workflow", |
| 114 | + "optimized database queries", |
| 115 | + "configured monitoring alerts", |
| 116 | + "updated security policies", |
| 117 | +]; |
| 118 | + |
| 119 | +function generateRandomActivity() { |
| 120 | + const firstName = firstNames[Math.floor(Math.random() * firstNames.length)]; |
| 121 | + const lastName = lastNames[Math.floor(Math.random() * lastNames.length)]; |
| 122 | + const action = actions[Math.floor(Math.random() * actions.length)]; |
| 123 | + |
| 124 | + // Generate timestamp within the last 30 days |
| 125 | + const now = new Date(); |
| 126 | + const thirtyDaysAgo = new Date(now.getTime() - 30 * 24 * 60 * 60 * 1000); |
| 127 | + const randomTime = new Date( |
| 128 | + thirtyDaysAgo.getTime() + |
| 129 | + Math.random() * (now.getTime() - thirtyDaysAgo.getTime()), |
| 130 | + ); |
| 131 | + |
| 132 | + return { |
| 133 | + id: Math.random().toString(36).substr(2, 9), |
| 134 | + name: `${firstName} ${lastName}`, |
| 135 | + action: action, |
| 136 | + timestamp: randomTime.toISOString(), |
| 137 | + }; |
| 138 | +} |
| 139 | + |
| 140 | +export default defineEventHandler((event) => { |
| 141 | + const activities = Array.from({ length: 20 }, () => generateRandomActivity()); |
| 142 | + activities.sort( |
| 143 | + (a, b) => new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime(), |
| 144 | + ); |
| 145 | + |
| 146 | + return { |
| 147 | + activities, |
| 148 | + total: activities.length, |
| 149 | + generated_at: new Date().toISOString(), |
| 150 | + }; |
| 151 | +}); |
0 commit comments