| 1 | package Daje::Helper::Kanban::Planboard; | ||
| 2 | use Mojo::Base -base, -signatures, -async_await; | ||
| 3 | use v5.42; | ||
| 4 | |||
| 5 | # NAME | ||
| 6 | # ==== | ||
| 7 | # | ||
| 8 | # Daje::Helper::Authorities::InsertPluginFunction - Daje helper | ||
| 9 | # | ||
| 10 | # SYNOPSIS | ||
| 11 | # ======== | ||
| 12 | # | ||
| 13 | # | ||
| 14 | # DESCRIPTION | ||
| 15 | # =========== | ||
| 16 | # | ||
| 17 | # Daje::Helper::Authorities::InsertPluginFunction a helper clas | ||
| 18 | # | ||
| 19 | # METHODS | ||
| 20 | # ======= | ||
| 21 | # | ||
| 22 | # | ||
| 23 | # | ||
| 24 | # | ||
| 25 | # SEE ALSO | ||
| 26 | # ======== | ||
| 27 | # | ||
| 28 | # Mojolicious, Mojolicious::Guides, https://mojolicious.org. | ||
| 29 | # | ||
| 30 | # LICENSE | ||
| 31 | # ======= | ||
| 32 | # | ||
| 33 | # Copyright (C) janeskil1525. | ||
| 34 | # | ||
| 35 | # This library is free software; you can redistribute it and/or modify | ||
| 36 | # it under the same terms as Perl itself. | ||
| 37 | # | ||
| 38 | # AUTHOR | ||
| 39 | # ====== | ||
| 40 | # | ||
| 41 | # janeskil1525 E<lt>janeskil1525@gmail.com | ||
| 42 | # | ||
| 43 | |||
| 44 | has 'db'; | ||
| 45 | |||
| 46 | |||
| 47 | async sub planboard_load($self, $companies_pkey, $users_pkey, $kanban_planboard_pkey) { | ||
| 48 | |||
| 49 | my $stmt = $self->get_statement(); | ||
| 50 | my $result->{result} = 0; | ||
| 51 | |||
| 52 | my $load = $self->db->query($stmt, $kanban_planboard_pkey); | ||
| 53 | $result->{data} = {}; | ||
| 54 | $result->{data} = $load->hash if $load and $load->rows > 0; | ||
| 55 | $result->{result} = 1; | ||
| 56 | return $result; | ||
| 57 | } | ||
| 58 | |||
| 59 | sub get_statement($self) { | ||
| 60 | return qq{ | ||
| 61 | select json_build_object('data', (SELECT json_agg(json_build_object( | ||
| 62 | 'kanban_list_pkey', kanban_list_pkey, | ||
| 63 | 'kanban_planboard_fkey',kanban_planboard_fkey, | ||
| 64 | 'sort_order', sort_order, | ||
| 65 | 'active', active, | ||
| 66 | 'title', title, | ||
| 67 | 'listid',listid, | ||
| 68 | 'cards',( | ||
| 69 | SELECT coalesce(json_agg( | ||
| 70 | json_build_object( | ||
| 71 | 'kanban_cards_pkey', kanban_cards_pkey, | ||
| 72 | 'kanban_list_fkey', kanban_list_fkey, | ||
| 73 | 'kanban_priority_fkey', kanban_priority_fkey, | ||
| 74 | 'sort_order', sort_order, | ||
| 75 | 'id', id, | ||
| 76 | 'title', title, | ||
| 77 | 'description', description, | ||
| 78 | 'progress', progress, | ||
| 79 | 'startdate', startdate, | ||
| 80 | 'duedate', duedate, | ||
| 81 | 'completed', completed, | ||
| 82 | 'priority', ( | ||
| 83 | SELECT json_build_object( | ||
| 84 | 'kanban_priority_pkey', kanban_priority_pkey, | ||
| 85 | 'color', color, | ||
| 86 | 'title', title | ||
| 87 | ) | ||
| 88 | FROM kanban_priority WHERE kanban_priority_pkey = kanban_priority_fkey | ||
| 89 | ), | ||
| 90 | 'taskList',(SELECT coalesce(json_agg(json_build_object( | ||
| 91 | 'kanban_tasks_pkey', kanban_tasks_pkey, | ||
| 92 | 'kanban_cards_fkey',kanban_cards_fkey, | ||
| 93 | 'id', id, | ||
| 94 | 'title', title, | ||
| 95 | 'booked', booked, | ||
| 96 | 'estimated', estimated, | ||
| 97 | 'completed', completed, | ||
| 98 | 'tasks', ( | ||
| 99 | SELECT json_agg(json_build_object( | ||
| 100 | 'kanban_task_pkey', kanban_task_pkey, | ||
| 101 | 'kanban_tasks_fkey', kanban_tasks_fkey, | ||
| 102 | 'text', text, | ||
| 103 | 'completed', completed | ||
| 104 | )) | ||
| 105 | FROM kanban_task WHERE kanban_tasks_pkey = kanban_tasks_fkey | ||
| 106 | ) | ||
| 107 | ) | ||
| 108 | ), '{"tasks":[]}'::json) | ||
| 109 | FROM kanban_tasks WHERE kanban_cards_pkey = kanban_cards_fkey | ||
| 110 | ), | ||
| 111 | 'comments', ( | ||
| 112 | SELECT coalesce(json_agg(json_build_object( | ||
| 113 | 'kanban_comments_pkey', kanban_comments_pkey, | ||
| 114 | 'kanban_cards_fkey', kanban_cards_fkey, | ||
| 115 | 'users_users_fkey', users_users_fkey, | ||
| 116 | 'id', id, | ||
| 117 | 'text', text | ||
| 118 | ) | ||
| 119 | ), '[]'::json) FROM kanban_comments WHERE kanban_cards_pkey = kanban_cards_fkey | ||
| 120 | ), | ||
| 121 | 'assignees', (SELECT coalesce(json_agg(json_build_object( | ||
| 122 | 'users_users_fkey', users_users_fkey, | ||
| 123 | 'comment', comment | ||
| 124 | )), '[]'::json) FROM kanban_assignees WHERE kanban_cards_pkey = kanban_cards_fkey) | ||
| 125 | |||
| 126 | ) | ||
| 127 | ), '[]'::JSON) FROM kanban_cards WHERE kanban_list_fkey = kanban_list_pkey | ||
| 128 | ) | ||
| 129 | ) | ||
| 130 | ) | ||
| 131 | FROM kanban_list WHERE kanban_planboard_fkey = ? | ||
| 132 | ) | ||
| 133 | ) | ||
| 134 | |||
| 135 | }; | ||
| 136 | } | ||
| 137 | 1; |