| 1 | package Daje::Helper::Authorities::InsertPluginFunction; | ||
| 2 | use Mojo::Base -base, -signatures; | ||
| 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 | sub process($self, $plugin, $functions) { | ||
| 47 | |||
| 48 | $self->db->query("INSERT INTO authorities_plugin (name) VALUES (?) ON CONFLICT(name) DO NOTHING",($plugin)); | ||
| 49 | |||
| 50 | my $stmt = qq{ | ||
| 51 | INSERT INTO authorities_function (name, authorities_plugin_fkey) | ||
| 52 | VALUES (?,( SELECT authorities_plugin_pkey FROM authorities_plugin WHERE name = ? )) | ||
| 53 | ON CONFLICT (name) DO NOTHING | ||
| 54 | }; | ||
| 55 | |||
| 56 | my $length = scalar @{$functions}; | ||
| 57 | for (my $i = 0; $i < $length; $i++) { | ||
| 58 | $self->db->query($stmt,(@{$functions}[$i], $plugin)); | ||
| 59 | } | ||
| 60 | } | ||
| 61 | |||
| 62 | 1; | ||
| 63 | |||
| 64 | |||
| 65 | #################### pod generated by Pod::Autopod - keep this line to make pod updates possible #################### | ||
| 66 | |||
| 67 | =head1 NAME | ||
| 68 | |||
| 69 | |||
| 70 | Daje::Helper::Authorities::InsertPluginFunction - Daje helper | ||
| 71 | |||
| 72 | |||
| 73 | |||
| 74 | =head1 SYNOPSIS | ||
| 75 | |||
| 76 | |||
| 77 | |||
| 78 | |||
| 79 | |||
| 80 | =head1 DESCRIPTION | ||
| 81 | |||
| 82 | |||
| 83 | Daje::Helper::Authorities::InsertPluginFunction a helper clas | ||
| 84 | |||
| 85 | |||
| 86 | |||
| 87 | =head1 REQUIRES | ||
| 88 | |||
| 89 | L<v5.42> | ||
| 90 | |||
| 91 | L<Mojo::Base> | ||
| 92 | |||
| 93 | |||
| 94 | =head1 METHODS | ||
| 95 | |||
| 96 | |||
| 97 | |||
| 98 | |||
| 99 | |||
| 100 | |||
| 101 | |||
| 102 | =head1 SEE ALSO | ||
| 103 | |||
| 104 | |||
| 105 | Mojolicious, Mojolicious::Guides, https://mojolicious.org. | ||
| 106 | |||
| 107 | |||
| 108 | |||
| 109 | =head1 AUTHOR | ||
| 110 | |||
| 111 | |||
| 112 | janeskil1525 E<lt>janeskil1525@gmail.com | ||
| 113 | |||
| 114 | |||
| 115 | |||
| 116 | =head1 LICENSE | ||
| 117 | |||
| 118 | |||
| 119 | Copyright (C) janeskil1525. | ||
| 120 | |||
| 121 | This library is free software; you can redistribute it and/or modify | ||
| 122 | it under the same terms as Perl itself. | ||
| 123 | |||
| 124 | |||
| 125 | |||
| 126 | =cut | ||
| 127 |