Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | CLASS zcl_abapgit_gui_page_sett_info DEFINITION PUBLIC INHERITING FROM zcl_abapgit_gui_component FINAL CREATE PRIVATE . PUBLIC SECTION. INTERFACES zif_abapgit_gui_event_handler . INTERFACES zif_abapgit_gui_renderable . CLASS-METHODS create IMPORTING !io_repo TYPE REF TO zcl_abapgit_repo RETURNING VALUE(ri_page) TYPE REF TO zif_abapgit_gui_renderable RAISING zcx_abapgit_exception . METHODS constructor IMPORTING !io_repo TYPE REF TO zcl_abapgit_repo RAISING zcx_abapgit_exception . PROTECTED SECTION. PRIVATE SECTION. TYPES: BEGIN OF ty_stats, measure TYPE string, local TYPE i, remote TYPE i, END OF ty_stats . TYPES: BEGIN OF ty_infos, size TYPE p LENGTH 16 DECIMALS 0, line TYPE p LENGTH 16 DECIMALS 0, sloc TYPE p LENGTH 16 DECIMALS 0, END OF ty_infos . CONSTANTS: BEGIN OF c_id, info TYPE string VALUE 'info', created_by TYPE string VALUE 'created_by', created_at TYPE string VALUE 'created_at', deserialized_by TYPE string VALUE 'deserialized_by', deserialized_at TYPE string VALUE 'deserialized_at', stats TYPE string VALUE 'stats', stats_table TYPE string VALUE 'stats_table', END OF c_id . DATA mo_form TYPE REF TO zcl_abapgit_html_form . DATA mo_form_data TYPE REF TO zcl_abapgit_string_map . DATA mo_repo TYPE REF TO zcl_abapgit_repo . DATA: mt_stats TYPE STANDARD TABLE OF ty_stats WITH KEY measure . METHODS get_form_schema RETURNING VALUE(ro_form) TYPE REF TO zcl_abapgit_html_form RAISING zcx_abapgit_exception . METHODS read_settings RAISING zcx_abapgit_exception . METHODS read_stats RAISING zcx_abapgit_exception . METHODS read_stats_files EXPORTING !et_local TYPE zif_abapgit_definitions=>ty_files_item_tt !et_remote TYPE zif_abapgit_git_definitions=>ty_files_tt RAISING zcx_abapgit_exception . METHODS read_stats_state RAISING zcx_abapgit_exception . METHODS read_stats_size_lines_sloc IMPORTING !it_local TYPE zif_abapgit_definitions=>ty_files_item_tt !it_remote TYPE zif_abapgit_git_definitions=>ty_files_tt EXPORTING !et_local_items TYPE zif_abapgit_definitions=>ty_items_tt !et_remote_items TYPE zif_abapgit_definitions=>ty_items_tt RAISING zcx_abapgit_exception . METHODS read_stats_file IMPORTING !is_file TYPE zif_abapgit_git_definitions=>ty_file RETURNING VALUE(rs_info) TYPE ty_infos . METHODS read_stats_objects CHANGING !ct_local_items TYPE zif_abapgit_definitions=>ty_items_tt !ct_remote_items TYPE zif_abapgit_definitions=>ty_items_tt RAISING zcx_abapgit_exception . METHODS format_user IMPORTING !iv_username TYPE syuname RETURNING VALUE(rv_user) TYPE string . METHODS format_timestamp IMPORTING !iv_timestamp TYPE timestampl RETURNING VALUE(rv_timestamp) TYPE string . METHODS format_size IMPORTING !iv_size TYPE i RETURNING VALUE(rv_size) TYPE string . ENDCLASS. CLASS zcl_abapgit_gui_page_sett_info IMPLEMENTATION. METHOD constructor. super->constructor( ). CREATE OBJECT mo_form_data. mo_repo = io_repo. mo_form = get_form_schema( ). ENDMETHOD. METHOD create. DATA lo_component TYPE REF TO zcl_abapgit_gui_page_sett_info. CREATE OBJECT lo_component EXPORTING io_repo = io_repo. ri_page = zcl_abapgit_gui_page_hoc=>create( iv_page_title = 'Repository Stats' io_page_menu = zcl_abapgit_gui_menus=>repo_settings( iv_key = io_repo->get_key( ) iv_act = zif_abapgit_definitions=>c_action-repo_infos ) ii_child_component = lo_component ). ENDMETHOD. METHOD format_size. DATA: lv_size TYPE p LENGTH 16 DECIMALS 2. IF iv_size > 1024 * 1024 * 1024. lv_size = iv_size / 1024 / 1024 / 1024. rv_size = |{ lv_size } GB|. ELSEIF iv_size > 1024 * 1024. lv_size = iv_size / 1024 / 1024. rv_size = |{ lv_size } MB|. ELSEIF iv_size > 1024. lv_size = iv_size / 1024. rv_size = |{ lv_size } KB|. ELSE. rv_size = |{ iv_size } Bytes|. ENDIF. ENDMETHOD. METHOD format_timestamp. DATA lv_short TYPE timestamp. IF iv_timestamp IS INITIAL. rv_timestamp = 'n/a'. RETURN. ENDIF. cl_abap_tstmp=>move( EXPORTING tstmp_src = iv_timestamp IMPORTING tstmp_tgt = lv_short ). rv_timestamp = |{ lv_short TIMESTAMP = ISO }|. ENDMETHOD. METHOD format_user. DATA lv_title TYPE string. IF iv_username IS INITIAL. rv_user = 'n/a'. RETURN. ENDIF. IF iv_username <> zcl_abapgit_objects_super=>c_user_unknown. lv_title = zcl_abapgit_user_record=>get_title( iv_username ). ENDIF. rv_user = iv_username. IF lv_title IS NOT INITIAL. rv_user = |{ rv_user } ({ lv_title })|. ENDIF. ENDMETHOD. METHOD get_form_schema. DATA lv_label TYPE string. ro_form = zcl_abapgit_html_form=>create( iv_form_id = 'repo-infos-form' iv_help_page = 'https://docs.abapgit.org/settings-stats.html' ). IF mo_repo->is_offline( ) = abap_true. lv_label = 'ZIP File'. ELSE. lv_label = 'Remote'. ENDIF. ro_form->start_group( iv_name = c_id-info iv_label = 'Stats' )->text( iv_name = c_id-created_by iv_label = 'Created By' iv_readonly = abap_true )->text( iv_name = c_id-created_at iv_label = 'Created At' iv_readonly = abap_true )->text( iv_name = c_id-deserialized_by iv_label = 'Last Deserialized By' iv_readonly = abap_true )->text( iv_name = c_id-deserialized_at iv_label = 'Last Deserialized At' iv_readonly = abap_true )->table( iv_name = c_id-stats_table iv_label = 'Statistics' )->column( iv_label = 'Measure' iv_width = '50%' iv_readonly = abap_true )->column( iv_label = 'Local' iv_width = '25%' iv_readonly = abap_true )->column( iv_label = lv_label iv_width = '25%' iv_readonly = abap_true )->command( iv_label = 'Back' iv_action = zif_abapgit_definitions=>c_action-go_back ). ENDMETHOD. METHOD read_settings. DATA: ls_repo TYPE zif_abapgit_persistence=>ty_repo, ls_stats TYPE ty_stats, lv_row TYPE i, lv_int TYPE i, lv_val TYPE string. " Get infos from DB TRY. ls_repo = zcl_abapgit_persist_factory=>get_repo( )->read( mo_repo->get_key( ) ). CATCH zcx_abapgit_not_found. zcx_abapgit_exception=>raise( |Repo not found, key { mo_repo->get_key( ) }| ). ENDTRY. read_stats( ). " Infos mo_form_data->set( iv_key = c_id-created_by iv_val = format_user( ls_repo-created_by ) ). mo_form_data->set( iv_key = c_id-created_at iv_val = format_timestamp( ls_repo-created_at ) ). mo_form_data->set( iv_key = c_id-deserialized_by iv_val = format_user( ls_repo-deserialized_by ) ). mo_form_data->set( iv_key = c_id-deserialized_at iv_val = format_timestamp( ls_repo-deserialized_at ) ). LOOP AT mt_stats INTO ls_stats. lv_row = sy-tabix. DO 3 TIMES. CASE sy-index. WHEN 1. lv_val = ls_stats-measure. WHEN 2. lv_val = ls_stats-local. WHEN 3. lv_val = ls_stats-remote. ENDCASE. IF ls_stats-measure CS 'Size' AND sy-index BETWEEN 2 AND 3. lv_int = lv_val. lv_val = format_size( lv_int ). ENDIF. mo_form_data->set( iv_key = |{ c_id-stats_table }-{ lv_row }-{ sy-index }| iv_val = lv_val ). ENDDO. ENDLOOP. mo_form_data->set( iv_key = |{ c_id-stats_table }-{ zif_abapgit_html_form=>c_rows }| iv_val = |{ lv_row }| ). ENDMETHOD. METHOD read_stats. DATA: lt_local TYPE zif_abapgit_definitions=>ty_files_item_tt, lt_remote TYPE zif_abapgit_git_definitions=>ty_files_tt, lt_local_items TYPE zif_abapgit_definitions=>ty_items_tt, lt_remote_items TYPE zif_abapgit_definitions=>ty_items_tt. CLEAR mt_stats. read_stats_files( IMPORTING et_local = lt_local et_remote = lt_remote ). read_stats_state( ). read_stats_size_lines_sloc( EXPORTING it_local = lt_local it_remote = lt_remote IMPORTING et_local_items = lt_local_items et_remote_items = lt_remote_items ). read_stats_objects( CHANGING ct_local_items = lt_local_items ct_remote_items = lt_remote_items ). ENDMETHOD. METHOD read_stats_file. TYPES ty_char255 TYPE c LENGTH 255. DATA: lv_code TYPE string, lt_code TYPE STANDARD TABLE OF ty_char255 WITH DEFAULT KEY. FIELD-SYMBOLS: <ls_code> LIKE LINE OF lt_code. rs_info-size = xstrlen( is_file-data ). IF is_file-filename CP '*.abap'. TRY. lv_code = zcl_abapgit_convert=>xstring_to_string_utf8( is_file-data ). CATCH zcx_abapgit_exception ##NO_HANDLER. ENDTRY. SPLIT lv_code AT cl_abap_char_utilities=>newline INTO TABLE lt_code. rs_info-line = lines( lt_code ). LOOP AT lt_code ASSIGNING <ls_code> WHERE table_line IS NOT INITIAL AND table_line(1) <> '*'. SHIFT <ls_code> LEFT DELETING LEADING space. IF <ls_code>(1) <> '"'. rs_info-sloc = rs_info-sloc + 1. ENDIF. ENDLOOP. ENDIF. ENDMETHOD. METHOD read_stats_files. DATA ls_stats TYPE ty_stats. DATA lt_remote_wo_ignored TYPE zif_abapgit_git_definitions=>ty_files_tt. et_local = mo_repo->get_files_local( ). ls_stats-measure = 'Number of Files'. ls_stats-local = lines( et_local ). IF mo_repo->has_remote_source( ) = abap_true. et_remote = mo_repo->get_files_remote( ). ls_stats-remote = lines( et_remote ). lt_remote_wo_ignored = mo_repo->get_files_remote( iv_ignore_files = abap_true ). ENDIF. APPEND ls_stats TO mt_stats. IF et_remote IS NOT INITIAL. CLEAR ls_stats. ls_stats-measure = 'Number of Ignored Files'. ls_stats-remote = lines( et_remote ) - lines( lt_remote_wo_ignored ). APPEND ls_stats TO mt_stats. ENDIF. ENDMETHOD. METHOD read_stats_objects. DATA: ls_stats TYPE ty_stats, ls_item TYPE zif_abapgit_definitions=>ty_item, lt_supported_types TYPE zcl_abapgit_objects=>ty_types_tt. ls_stats-measure = 'Number of Objects'. DELETE ct_local_items WHERE obj_type IS INITIAL OR obj_name IS INITIAL. ls_stats-local = lines( ct_local_items ). DELETE ct_remote_items WHERE obj_type IS INITIAL OR obj_name IS INITIAL. ls_stats-remote = lines( ct_remote_items ). APPEND ls_stats TO mt_stats. CLEAR ls_stats. ls_stats-measure = 'Number of Unsupported Objects'. ls_stats-local = lines( mo_repo->get_unsupported_objects_local( ) ). lt_supported_types = zcl_abapgit_objects=>supported_list( ). LOOP AT ct_remote_items INTO ls_item. READ TABLE lt_supported_types WITH KEY table_line = ls_item-obj_type TRANSPORTING NO FIELDS. IF sy-subrc <> 0. ls_stats-remote = ls_stats-remote + 1. ENDIF. ENDLOOP. APPEND ls_stats TO mt_stats. ENDMETHOD. METHOD read_stats_size_lines_sloc. DATA: ls_stats TYPE ty_stats, lv_ignored TYPE abap_bool, ls_info_file TYPE ty_infos, ls_info_local TYPE ty_infos, ls_info_remote TYPE ty_infos, ls_item TYPE zif_abapgit_definitions=>ty_item. FIELD-SYMBOLS: <ls_local> LIKE LINE OF it_local, <ls_remote> LIKE LINE OF it_remote. LOOP AT it_local ASSIGNING <ls_local>. ls_info_file = read_stats_file( <ls_local>-file ). ls_info_local-size = ls_info_local-size + ls_info_file-size. ls_info_local-line = ls_info_local-line + ls_info_file-line. ls_info_local-sloc = ls_info_local-sloc + ls_info_file-sloc. COLLECT <ls_local>-item INTO et_local_items. ENDLOOP. IF mo_repo->has_remote_source( ) = abap_true. LOOP AT it_remote ASSIGNING <ls_remote> WHERE filename IS NOT INITIAL. lv_ignored = mo_repo->get_dot_abapgit( )->is_ignored( iv_filename = <ls_remote>-filename iv_path = <ls_remote>-path ). IF lv_ignored = abap_false. ls_info_file = read_stats_file( <ls_remote> ). ls_info_remote-size = ls_info_remote-size + ls_info_file-size. ls_info_remote-line = ls_info_remote-line + ls_info_file-line. ls_info_remote-sloc = ls_info_remote-sloc + ls_info_file-sloc. TRY. zcl_abapgit_filename_logic=>file_to_object( EXPORTING iv_filename = <ls_remote>-filename iv_path = <ls_remote>-path iv_devclass = mo_repo->get_package( ) io_dot = mo_repo->get_dot_abapgit( ) IMPORTING es_item = ls_item ). COLLECT ls_item INTO et_remote_items. CATCH zcx_abapgit_exception ##NO_HANDLER. ENDTRY. ENDIF. ENDLOOP. ENDIF. ls_stats-measure = 'Size of Files'. ls_stats-local = ls_info_local-size. ls_stats-remote = ls_info_remote-size. APPEND ls_stats TO mt_stats. ls_stats-measure = 'Lines in ABAP Files'. ls_stats-local = ls_info_local-line. ls_stats-remote = ls_info_remote-line. APPEND ls_stats TO mt_stats. ls_stats-measure = 'Lines of Code in ABAP Files'. ls_stats-local = ls_info_local-sloc. ls_stats-remote = ls_info_remote-sloc. APPEND ls_stats TO mt_stats. ENDMETHOD. METHOD read_stats_state. DATA: lt_results TYPE zif_abapgit_definitions=>ty_results_tt, lv_state TYPE c LENGTH 1, ls_stats TYPE ty_stats. FIELD-SYMBOLS: <ls_result> LIKE LINE OF lt_results. lt_results = zcl_abapgit_repo_status=>calculate( mo_repo ). DO 3 TIMES. CLEAR ls_stats. CASE sy-index. WHEN 1. ls_stats-measure = 'Number of Modified Files'. lv_state = zif_abapgit_definitions=>c_state-modified. WHEN 2. ls_stats-measure = 'Number of Added Files'. lv_state = zif_abapgit_definitions=>c_state-added. WHEN 3. ls_stats-measure = 'Number of Deleted Files'. lv_state = zif_abapgit_definitions=>c_state-deleted. ENDCASE. LOOP AT lt_results ASSIGNING <ls_result>. IF <ls_result>-lstate = lv_state. ls_stats-local = ls_stats-local + 1. ENDIF. IF <ls_result>-rstate = lv_state AND mo_repo->has_remote_source( ) = abap_true. ls_stats-remote = ls_stats-remote + 1. ENDIF. ENDLOOP. APPEND ls_stats TO mt_stats. ENDDO. ENDMETHOD. METHOD zif_abapgit_gui_event_handler~on_event. IF ii_event->mv_action = zif_abapgit_definitions=>c_action-go_back. rs_handled-state = zcl_abapgit_gui=>c_event_state-go_back_to_bookmark. ENDIF. ENDMETHOD. METHOD zif_abapgit_gui_renderable~render. register_handlers( ). read_settings( ). CREATE OBJECT ri_html TYPE zcl_abapgit_html. ri_html->add( `<div class="repo">` ). ri_html->add( zcl_abapgit_gui_chunk_lib=>render_repo_top( io_repo = mo_repo iv_show_commit = abap_false iv_interactive_branch = abap_true ) ). ri_html->add( mo_form->render( mo_form_data ) ). ri_html->add( `</div>` ). ENDMETHOD. ENDCLASS. |