1. Python / Говнокод #27273

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    import math
    import argparse
    
    parser = argparse.ArgumentParser()
    parser.add_argument("--type")
    parser.add_argument("--principal", type=int)
    parser.add_argument("--periods", type=int)
    parser.add_argument("--interest", type=float)
    parser.add_argument("--payment", type=float)
    
    args = parser.parse_args()
    
    choose = args.type
    p = args.principal
    n = args.periods
    i = args.interest
    a = args.payment
    
    if i is None or p is None and a is None:
        print("Incorrect parameters.")
        exit(0)
    
    i = (i * 0.01) / (12 * 1)
    
    if choose == "diff":
        m = 1
        overpayment_all = 0
        while m <= n:
            d = math.ceil(p / n + i * (p - ((p * (m - 1)) / n)))
            m += 1
            overpayment_all += d
            print(f"Month {m - 1}: payment is {d}")
        print()
        print(f"Overpayment = {overpayment_all - p}")
    
    elif choose == "annuity" and a is None:
        a = math.ceil(p * (i * math.pow((1 + i), n)) / (math.pow((1 + i), n) - 1))
        print(f"Your monthly payment = {a}!")
        over = a * n - p
        print(f"Overpayment = {math.ceil(over)}")
    
    elif choose == "annuity" and p is None:
        p = int(a / (i * math.pow(1 + i, n) / (math.pow(1 + i, n) - 1)))
        print(f"Your loan principal = {p}!")
        m = 1
        over = a * n - p
        print(f"Overpayment = {math.ceil(over)}")
    
    elif choose == "annuity":
        n = math.ceil(math.log(a / (a - i * p), 1 + i))
        zxc = math.ceil(math.log(a / (a - i * p), 1 + i))
        years = 0
        while n >= 12:
            n -= 12
            years += 1
        if years == 0:
            print(f"It will take {n} months to repay this loan!")
            over = a * zxc - p
            print(f"Overpayment = {math.ceil(over)}")
        elif n == 0:
            print(f"It will take {years} years to repay this loan!")
            over = a * zxc - p
            print(f"Overpayment = {math.ceil(over)}")
        else:
            print(f"It will take {years} years and {n} months to repay this loan!")
            over = a * zxc - p
            print(f"Overpayment = {math.ceil(over)}")

    Ебучий универ и ебучее задание на питоне. Всё было бы збс, если бы не математика.
    Прога считает проценты, бабки, переплаты и чёт ещё, наверное

    warzon131, 25 Февраля 2021

    Комментарии (12)
  2. JavaScript / Говнокод #27272

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    var utils = require('util');
    
    module.exports = class Client {
        constructor(Socket) {
    
            this.Socket = Socket;
            this.TLSSocket = require('tls');
            this.XmlParser = new require('xml2js').Parser();
            this.XmlBuilder = require('xmlbuilder');
            this.Client = this;
            this.Authorized = false;
            this.OnlineId = '1';
            this.Socket.on('data', (Packet) => this.OnData(Packet));
            this.Player = null;
            this.Status = 0;
        }
    // Авторизация.
        OnData(Packet) {
            if (Packet[0] == 0xad || Packet[1] == 0xde || Packet[2] == 0xed || Packet[3] == 0xfe) {
                var PacketBuffer = Buffer.alloc(Number(Packet.readBigInt64LE(4)));
                Packet.copy(PacketBuffer, 0, 12);
                var Query = PacketBuffer.toString();
                console.log('[CLIENT] ',Query);
                this.XmlParser.parseString(PacketBuffer.toString(), (err, result) => {
                    if (result) 
                    {
                        if (result.starttls && !this.TLSSocket.Authorized && !this.Authorized) {
                            this.Send(this.XmlBuilder.create({
                                proceed: {
                                    '@xmlns': 'urn:ietf:params:xml:ns:xmpp-tls'
                                }
                            }, {
                                    headless: true
                                }).end({
                                    pretty: false
                                }));
                            this.TLSSocket = new this.TLSSocket.TLSSocket(this.Socket, {
                                cert: global.Cert,
                                key: global.CertKey,
                                ca: global.CertBundle,
                                minVersion: 'TLSv1',
                                isServer: true
                            })
                            this.TLSSocket.once('secure', () => {
                                this.TLSSocket.Authorized = true;
                                console.log('TLS Connection established!');
                            });
                            this.TLSSocket.on('data', (Packet)=>this.OnData(Packet));
    
                        }
                        else if (result.iq && result.iq.bind) {
                            this.Send(this.XmlBuilder.create({
                                iq: {
                                    '@id': result.iq.$.id,
                                    '@type': 'result',
                                    bind: {
                                        '@xmlns': 'urn:ietf:params:xml:ns:xmpp-bind',
                                        jid: this.OnlineId
                                    }
                                }
                            }, {
                                headless: true
                            }).end({
                                pretty: false
                            }));
                        } else if (result.iq && result.iq.session) {
                            this.Send(this.XmlBuilder.create({
                                iq: {
                                    '@id': result.iq.$.id,
                                    '@type': 'result',
                                    '@to': this.OnlineId,
                                    session: {
                                        '@xmlns': 'urn:ietf:params:xml:ns:xmpp-session'
                                    }
                                }
                            }, {
                                headless: true
                            }).end({
                                pretty: false
                            }));
                        }
                        else if (result.iq && result.iq.query) {
    
                            var QueryName = Object.keys(result.iq.query[0]).filter(function (str) {
                                return str != '_' && str != '$'
                            })[0];
    
                            var QueryFunction = global.PacketFactory[QueryName];
    
                            if (QueryFunction) {
                                var Stanza = result.iq.query[0][QueryName][0];
    
                                console.log(`\x1b[32mQueryname: ${QueryName} ${utils.inspect(Stanza.$)}\x1b[0m`);
                                global.PacketFactory[QueryName].handle(this, Stanza, result.iq.$.to, result.iq.$.id);
                            }

    Nodejs вход пользователя

    Seagate, 25 Февраля 2021

    Комментарии (16)
  3. C++ / Говнокод #27271

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    // -------------------------------------------
    // 2.2. binary calls
    // -------------------------------------------
    /*
        combination table:
    
          +-   | c a n
            ---|-------
             c | C A N
             a | A A N
             n | N N N
    
          *    | c a n
            ---|-------
             c | C A N
             a | A N N
             n | N N N
    
          /    | c a n
            ---|-------
             c | C N N
             a | A N N
             n | N N N
    
        argument:
          c : constant, as scalar, point, tensor, ect
          l : affine homogeneous expr argument: as field, field_indirect or field_expr_node::is_affine_homogeneous
          n : function, functor or ! field_expr_node::is_affine_homogeneous
        result:
          C : constant : this combination is not implemented here
          A,N : are implemented here
        rules:
          at least one of the two args is not of type "c"
          when c: c value is embeded in bind_first or bind_second
                  and the operation reduces to an unary one
          when a: if it is a field_convertible, it should be wrapped
                  in field_expr_v2_nonlinear_terminal_field
          when c: no wrapper is need
        implementation:
          The a and n cases are grouped, thanks to the wrapper_traits
          and it remains to cases :
            1) both args are  field_expr_v2_nonlinear or a function 
            2) one  arg  is a field_expr_v2_nonlinear or a function and the second argument is a constant
    */
    
    #define _RHEOLEF_make_field_expr_v2_nonlinear_binary(FUNCTION,FUNCTOR)	\
    template<class Expr1, class Expr2>						\
    inline										\
    typename									\
    std::enable_if<									\
         details::is_field_expr_v2_nonlinear_arg<Expr1>::value			\
      && details::is_field_expr_v2_nonlinear_arg<Expr2>::value			\
      && ! details::is_field_expr_v2_constant   <Expr1>::value			\
      && ! details::is_field_expr_v2_constant   <Expr2>::value			\
     ,details::field_expr_v2_nonlinear_node_binary<					\
        FUNCTOR									\
       ,typename details::field_expr_v2_nonlinear_terminal_wrapper_traits<Expr1>::type	\
       ,typename details::field_expr_v2_nonlinear_terminal_wrapper_traits<Expr2>::type 	\
      >										\
    >::type										\
    FUNCTION (const Expr1& expr1, const Expr2& expr2)				\
    {										\
      typedef typename details::field_expr_v2_nonlinear_terminal_wrapper_traits<Expr1>::type wrap1_t; \
      typedef typename details::field_expr_v2_nonlinear_terminal_wrapper_traits<Expr2>::type wrap2_t; \
      return details::field_expr_v2_nonlinear_node_binary <FUNCTOR,wrap1_t,wrap2_t> \
    	(FUNCTOR(), wrap1_t(expr1), wrap2_t(expr2)); 				\
    }										\
    template<class Expr1, class Expr2>						\
    inline										\
    typename 									\
    std::enable_if<									\
         details::is_field_expr_v2_constant     <Expr1>::value			\
      && details::is_field_expr_v2_nonlinear_arg<Expr2>::value			\
      && ! details::is_field_expr_v2_constant   <Expr2>::value			\
     ,details::field_expr_v2_nonlinear_node_unary<					\
        details::binder_first<							\
          FUNCTOR									\
         ,typename details::field_promote_first_argument<				\
            Expr1

    MAKAKA, 25 Февраля 2021

    Комментарии (19)
  4. Куча / Говнокод #27270

    0

    1. 1
    IT Оффтоп #80

    #50: https://govnokod.ru/26804 https://govnokod.xyz/_26804
    #51: https://govnokod.ru/26809 https://govnokod.xyz/_26809
    #52: https://govnokod.ru/26817 https://govnokod.xyz/_26817
    #53: https://govnokod.ru/26833 https://govnokod.xyz/_26833
    #54: https://govnokod.ru/26840 https://govnokod.xyz/_26840
    #55: https://govnokod.ru/26844 https://govnokod.xyz/_26844
    #56: https://govnokod.ru/26862 https://govnokod.xyz/_26862
    #57: https://govnokod.ru/26890 https://govnokod.xyz/_26890
    #58: https://govnokod.ru/26916 https://govnokod.xyz/_26916
    #59: https://govnokod.ru/26934 https://govnokod.xyz/_26934
    #60: https://govnokod.ru/26949 https://govnokod.xyz/_26949
    #61: https://govnokod.ru/26980 https://govnokod.xyz/_26980
    #62: https://govnokod.ru/26999 https://govnokod.xyz/_26999
    #63: https://govnokod.ru/27004 https://govnokod.xyz/_27004
    #64: https://govnokod.ru/27020 https://govnokod.xyz/_27020
    #65: https://govnokod.ru/27027 https://govnokod.xyz/_27027
    #66: https://govnokod.ru/27040 https://govnokod.xyz/_27040
    #67: https://govnokod.ru/27049 https://govnokod.xyz/_27049
    #68: https://govnokod.ru/27061 https://govnokod.xyz/_27061
    #69: https://govnokod.ru/27071 https://govnokod.xyz/_27071
    #70: https://govnokod.ru/27097 https://govnokod.xyz/_27097
    #71: https://govnokod.ru/27115 https://govnokod.xyz/_27115
    #72: https://govnokod.ru/27120 https://govnokod.xyz/_27120
    #73: https://govnokod.ru/27136 https://govnokod.xyz/_27136
    #74: https://govnokod.ru/27160 https://govnokod.xyz/_27160
    #75: https://govnokod.ru/27166 https://govnokod.xyz/_27166
    #76: https://govnokod.ru/27168 https://govnokod.xyz/_27168
    #77: https://govnokod.ru/27186 https://govnokod.xyz/_27186
    #78: https://govnokod.ru/27219 https://govnokod.xyz/_27219
    #79: https://govnokod.ru/27254 https://govnokod.xyz/_27254

    nepeKamHblu_nemyx, 25 Февраля 2021

    Комментарии (3805)
  5. PHP / Говнокод #27269

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    <?php
    require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php"); 
    
    if($_POST['SESS_PARAM'] && $_POST['SESS_PARAM'] !='' && $_POST['SESS_PARAM_VALUE'] && $_POST['SESS_PARAM_VALUE'] !=''){
    
    	$_SESSION[$_POST['SESS_PARAM']] = $_POST['SESS_PARAM_VALUE'];
    	echo 'ok';
    }else{
    	echo 'error';
    }

    утверждают что сайт им писали лучшие из лучших

    BroadcastAddress, 23 Февраля 2021

    Комментарии (143)
  6. bash / Говнокод #27268

    0

    1. 1
    $ find ~ -name .git -type d -prune -printf "***\n%p\n***\n" -exec git -C '{}/..' status  \;

    MAKAKA, 21 Февраля 2021

    Комментарии (128)
  7. C++ / Говнокод #27267

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    #include <iostream>
    #include <ctime>
    using namespace std;
    
    #define SIZE 200000000
    
    struct StackRazrivator {
    	int data[SIZE];
    };
    
    void razorvi() {
    	cout << "nachinau razrivat\n";
    	StackRazrivator r;
    }
    
    void razrivator() {
    	cout << "razrivator\n";
    	razorvi();
    }
    
    int main() {
        cout << "start" << endl;
    	razrivator();
    	return 0;
    }

    Что выведет программа, если скомпилировать без оптимизаций и почему?

    https://godbolt.org/z/75Yzer

    3_dar, 20 Февраля 2021

    Комментарии (64)
  8. Си / Говнокод #27266

    +3

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    // https://deadlockempire.github.io/
    // Игра, где надо играть за планировщик чтоб вызвать дедлок
    
    // https://deadlockempire.github.io/#2-flags
    
    // First Army
    
    while (true) {
      while (flag != false) {
        ;
      }
      flag = true;
      critical_section();
      flag = false;
    }
    
    // Second Army
    
    while (true) {
      while (flag != false) {
        ;
      }
      flag = true;
      critical_section();
      flag = false;
    }

    The day finally came. The Deadlock Empire opened its gates and from them surged massive amounts of soldiers, loyal servants of the evil Parallel Wizard. The Wizard has many strengths - his armies are fast, and he can do a lot of stuff that we can't. But now he set out to conquer the world, and we cannot have that.

    You are our best Scheduler, commander! We have fewer troops and simpler ones, so we will need your help. Already two armies of the Deadlock Empire are approaching our border keeps. They are poorly equipped and poorly trained, however. You might be able to desync them and break their morale.

    j123123, 20 Февраля 2021

    Комментарии (60)
  9. JavaScript / Говнокод #27265

    +2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    function main()
    {
    	f1();
    }
    
    function f1(a = 10)
    {    
        return a;
    }
    
    // code for 1
    
    module @"1.ts"  {
      func @main() {
        %c0_i32 = constant 0 : i32
        %0 = typescript.undef : i32
        %1 = call @f1(%c0_i32, %0) : (i32, i32) -> i32
        return
      }
      func private @f1(%arg0: i32, %arg1: i32) -> i32 attributes {OptionalFrom = 1 : i8} {
        %c10_i32 = constant 10 : i32
        %c1_i32 = constant 1 : i32
        %0 = alloca() : memref<i32>
        %1 = cmpi ult, %arg0, %c1_i32 : i32
        %2 = scf.if %1 -> (i32) {
          scf.yield %c10_i32 : i32
        } else {
          scf.yield %arg1 : i32
        }
        store %2, %0[] : memref<i32>
        %3 = load %0[] : memref<i32>
        return %3 : i32
      }
    }
    
    // code for 2
    
    ; ModuleID = 'LLVMDialectModule'
    source_filename = "LLVMDialectModule"
    target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
    target triple = "x86_64-pc-windows-msvc"
    
    declare i8* @malloc(i64)
    
    declare void @free(i8*)
    
    define void @main() !dbg !3 {
      %1 = call i32 @f1(i32 0, i32 undef), !dbg !7
      ret void, !dbg !9
    }
    
    define i32 @f1(i32 %0, i32 %1) !dbg !10 {
      %3 = alloca i32, i64 ptrtoint (i32* getelementptr (i32, i32* null, i64 1) to i64), align 4, !dbg !11
      %4 = insertvalue { i32*, i32*, i64 } undef, i32* %3, 0, !dbg !11
      %5 = insertvalue { i32*, i32*, i64 } %4, i32* %3, 1, !dbg !11
      %6 = insertvalue { i32*, i32*, i64 } %5, i64 0, 2, !dbg !11
      %7 = icmp ult i32 %0, 1, !dbg !11
      br i1 %7, label %8, label %9, !dbg !11
    
    8:                                                ; preds = %2
      br label %10, !dbg !11
    
    9:                                                ; preds = %2
      br label %10, !dbg !11
    
    10:                                               ; preds = %8, %9
      %11 = phi i32 [ %1, %9 ], [ 10, %8 ]
      br label %12, !dbg !11
    
    12:                                               ; preds = %10
      %13 = extractvalue { i32*, i32*, i64 } %6, 1, !dbg !11
      store i32 %11, i32* %13, align 4, !dbg !11
      %14 = extractvalue { i32*, i32*, i64 } %6, 1, !dbg !11
      %15 = load i32, i32* %14, align 4, !dbg !11
      ret i32 %15, !dbg !13
    }

    История о том как я компайлер писал. (предисторию знают думаю все). Посмотрите на код и сравните с ужасным кодом на С. Это простенький javascript который тоже може быть скомпиленным в исполняемый год. а что для этого надо. просто несколько шагов.

    1) компилим код через чудо компилятор tsc.exe --emit=mlir-affine c:\1.ts



    а дальше может получить LLVM IL который можно компилировать

    2) компилим код через чудо компилятор tsc.exe --emit=mlir-llvm c:\1.ts



    а далее компилим код

    llc.exe --filetype=obj -o=out.o 1.ll


    запускаем a.exe

    и оно работает :)

    ASD_77, 19 Февраля 2021

    Комментарии (30)
  10. SQL / Говнокод #27264

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    SELECT sum(t4.value) as "План", STR_TO_DATE(t4.date, '%d-%m-%Y') AS "time" FROM
    (SELECT  t.id, t.subject, t3.depth, t.value, 
       CASE WHEN t.field_name = "Август 2020 (план)" THEN "2020-08-01"
      WHEN t.field_name = "Август 2020 (факт)" THEN "2020-08-01"
      WHEN t.field_name = "Апрель 2020 (план)" THEN "2020-04-01"
      WHEN t.field_name = "Апрель 2020 (факт)" THEN "2020-04-01"
      WHEN t.field_name = "Декабрь 2020 (план)" THEN "2020-12-01"
      WHEN t.field_name = "Декабрь 2020 (факт)" THEN "2020-12-01"
      WHEN t.field_name = "Июль 2020 (план)" THEN "2020-07-01"
      WHEN t.field_name = "Июль 2020 (факт)" THEN "2020-07-01"
      WHEN t.field_name = "Июнь 2020 (план)" THEN "2020-06-01"
      WHEN t.field_name = "Июнь 2020 (факт)" THEN "2020-06-01"
      WHEN t.field_name = "Май 2020 (план)" THEN "2020-05-01"
      WHEN t.field_name = "Май 2020 (факт)" THEN "2020-05-01"
      WHEN t.field_name = "Март 2020 (план)" THEN "2020-03-01"
      WHEN t.field_name = "Март 2020 (факт)" THEN "2020-03-01"
      WHEN t.field_name = "Ноябрь 2020 (план)" THEN "2020-11-01"
      WHEN t.field_name = "Ноябрь 2020 (факт)" THEN "2020-11-01"
      WHEN t.field_name = "Октябрь 2020 (план)" THEN "2020-10-01"
      WHEN t.field_name = "Октябрь 2020 (факт)" THEN "2020-10-01"
      WHEN t.field_name = "Сентябрь 2020 (план)" THEN "2020-09-01"
      WHEN t.field_name = "Сентябрь 2020 (факт)" THEN "2020-09-01"
      WHEN t.field_name = "Февраль 2020 (план)" THEN "2020-02-01"
      WHEN t.field_name = "Февраль 2020 (факт)" THEN "2020-02-01"
      WHEN t.field_name = "Январь 2020 (план)" THEN "2020-01-01"
      WHEN t.field_name = "Январь 2020 (факт)" THEN "2020-01-01" end AS DATE
       FROM (
              SELECT i.id AS id, i.subject AS subject, i.updated_on as updated_on,
                cf.name AS field_name,
                cv.value AS value
              FROM issues i
            LEFT JOIN custom_values cv
                ON i.id = cv.customized_id
            LEFT JOIN custom_fields cf
                ON cv.custom_field_id=cf.id      
             WHERE cv.customized_type="Issue" and (i.project_id = 2284)) t 
       LEFT join
       (SELECT  t2.id,
      GROUP_CONCAT(DISTINCT(CASE WHEN t2.field_name = "Код бюджета" THEN t2.value else null END)) AS depth   
       FROM (
              SELECT i.id AS id, i.subject AS subject, i.updated_on as updated_on,
                cf.name AS field_name,
                cv.value AS value
              FROM issues i
            LEFT JOIN custom_values cv
                ON i.id = cv.customized_id
            LEFT JOIN custom_fields cf
                ON cv.custom_field_id=cf.id      
             WHERE cv.customized_type="Issue" and (i.project_id = 2284)) t2
       GROUP BY t2.id) t3        
       ON t.id=t3.id
       WHERE INSTR(t.field_name, "план")>0 ) t4
       WHERE substr(t4.date,1,7) in ($time)  and t4.value!=0 and t4.depth=1 and t4.subject = 'Себестоимость реализованной готовой продукции (товаров, работ, услуг)'
       group by t4.date

    https://t.me/dba_ru/131122

    Fike, 19 Февраля 2021

    Комментарии (14)