LCOV - code coverage report
Current view: top level - src/esys/repo/gitstats - datayear.cpp (source / functions) Hit Total Coverage
Test: esysrepo_coverage.info Lines: 23 38 60.5 %
Date: 2026-08-01 10:43:40 Functions: 6 11 54.5 %

          Line data    Source code
       1             : /*!
       2             :  * \file esys/repo/gitstats/datayear.cpp
       3             :  * \brief
       4             :  *
       5             :  * \cond
       6             :  * __legal_b__
       7             :  *
       8             :  * Copyright (c) 2022 Michel Gillet
       9             :  * Distributed under the MIT License.
      10             :  * (See accompanying file LICENSE.txt or
      11             :  * copy at https://opensource.org/licenses/MIT)
      12             :  *
      13             :  * __legal_e__
      14             :  * \endcond
      15             :  *
      16             :  */
      17             : 
      18             : #include "esys/repo/esysrepo_prec.h"
      19             : #include "esys/repo/gitstats/datayear.h"
      20             : 
      21             : #include <cassert>
      22             : 
      23             : namespace esys::repo::gitstats
      24             : {
      25             : 
      26           0 : DataYear::DataYear() = default;
      27             : 
      28           1 : DataYear::DataYear(unsigned int year)
      29           1 :     : m_year(year)
      30             : {
      31           1 : }
      32             : 
      33           1 : DataYear::~DataYear() = default;
      34             : 
      35           0 : void DataYear::set_year(unsigned int year)
      36             : {
      37           0 :     m_year = year;
      38           0 : }
      39             : 
      40           1 : unsigned int DataYear::get_year() const
      41             : {
      42           1 :     return m_year;
      43             : }
      44             : 
      45           0 : std::shared_ptr<DataPeriod> DataYear::get_week(unsigned int week)
      46             : {
      47           0 :     assert(week < 52);
      48             : 
      49           0 :     return m_weeks[week];
      50             : }
      51             : 
      52           4 : std::shared_ptr<DataPeriod> DataYear::get_week_or_new(unsigned int week)
      53             : {
      54           4 :     assert(week < 52);
      55             : 
      56           4 :     if (m_weeks[week] == nullptr) m_weeks[week] = std::make_shared<DataPeriod>(week);
      57             : 
      58           4 :     return m_weeks[week];
      59             : }
      60             : 
      61           0 : std::shared_ptr<DataPeriod> DataYear::get_month(unsigned int month)
      62             : {
      63           0 :     assert(month < 12);
      64             : 
      65           0 :     return m_months[month];
      66             : }
      67             : 
      68           0 : std::shared_ptr<DataPeriod> DataYear::get_month_or_new(unsigned int month)
      69             : {
      70           0 :     assert(month < 12);
      71             : 
      72           0 :     if (m_months[month] == nullptr) m_months[month] = std::make_shared<DataPeriod>(month);
      73             : 
      74           0 :     return m_months[month];
      75             : }
      76             : 
      77           1 : unsigned int DataYear::get_weeks_with_data_count() const
      78             : {
      79           1 :     unsigned int count = 0;
      80             : 
      81          53 :     for (auto week : m_weeks)
      82             :     {
      83          52 :         if (week != nullptr) ++count;
      84          52 :     }
      85             : 
      86           1 :     return count;
      87             : }
      88             : 
      89           3 : std::shared_ptr<DataPeriod> DataYear::get_weeks_with_data(unsigned int idx)
      90             : {
      91           3 :     unsigned int count = 0;
      92             : 
      93          55 :     for (auto week : m_weeks)
      94             :     {
      95          55 :         if (week != nullptr)
      96             :         {
      97           6 :             if (count == idx) return week;
      98           3 :             ++count;
      99             :         }
     100          55 :     }
     101           0 :     return nullptr;
     102             : }
     103             : 
     104             : } // namespace esys::repo::gitstats

Generated by: LCOV version 1.14