Showing 2 changed files with 28 additions and 0 deletions
+7
lib/Gitprep.pm
... ...
@@ -238,6 +238,13 @@ sub startup {
238 238
           . ' on target_project.user = target_project__user.row_id'
239 239
       ]
240 240
     },
241
+    {
242
+      table => 'label',
243
+      primary_key => 'row_id',
244
+      join => [
245
+        'left join project on label.project = project.row_id'
246
+      ]
247
+    }
241 248
   ];
242 249
   $dbi->create_model($_) for @$models;
243 250
   $dbi->setup_model;
+21
templates/issues.html.ep
... ...
@@ -42,6 +42,27 @@
42 42
       {'issue.open' => 0, pull_request => 0, 'project.id' => $project_id}
43 43
     ]
44 44
   )->value;
45
+  
46
+  # Initialize labels if there are no labels
47
+  my $labels_count = app->dbi->model('label')->select('count(*)')->value;
48
+  if ($labels_count == 0) {
49
+    my @labels = (
50
+      {id => 'bug', color => '#fc2929'},
51
+      {id => 'duplicate', color => '#cccccc'},
52
+      {id => 'enhancement', color => '#84b6eb'},
53
+      {id => 'invalid', color => '#e6e6e6'},
54
+      {id => 'question', color => '#cc317c'},
55
+      {id => 'wontfix', color => '#ffffff'}
56
+    );
57
+    for my $label (@labels) {
58
+      my $project_row_id = app->dbi->model('project')->select(
59
+        'project.row_id',
60
+        where => {'user.id' => $user_id, 'project.id' => $project_id}
61
+      )->value;
62
+      $label->{project} = $project_row_id;
63
+      app->dbi->model('label')->insert($label);
64
+    }
65
+  }
45 66
 
46 67
   layout 'common', title => "Issues - $user_id/$project_id";
47 68
 %>