{#
SPDX-License-Identifier: Apache-2.0
SPDX-FileCopyrightText: 2025 The Linux Foundation
#}

{#- Section: Organizations (HTML) -#}
{#- Renders the organizations section with top organization tables -#}
{#-
    Context required:
        - organizations (dict): Organization data and lists
        - config (dict): Configuration options

    This section displays:
        - Top organizations by commit count
        - Organization statistics
        - Contributor counts per organization
-#}

{% if config.include_sections.organizations and organizations.has_organizations %}
<section id="organizations" class="report-section organizations-section">
    <h2>🏢 Top Organizations</h2>

    <p>The data presented in the table below covers the past 365 days.</p>

    <p><strong>Organizations Found:</strong> {{ organizations.total_count | default(0) }}</p>

    <table class="dt-enabled dt-no-pagination">
        <thead>
            <tr>
                <th>Rank</th>
                <th>Organization</th>
                <th>Contributors</th>
                <th>Commits</th>
                <th>LOC+</th>
                <th>LOC−</th>
                <th>LOCΔ</th>
                <th>LOC±</th>
                <th>LOC/Commit</th>
                <th>Repos</th>
            </tr>
        </thead>
        <tbody>
            {% for org in organizations.top %}
            <tr>
                <td>{{ loop.index }}</td>
                <td>{{ org.name | default('Unknown') }}</td>
                <td>{{ org.unique_contributors | default(0) }}</td>
                <td>{{ org.total_commits | default(0) }}</td>
                <td>{{ org.total_lines_added | format_loc }}</td>
                <td>{{ org.total_lines_removed | format_loc }}</td>
                <td>{{ org.net_lines | format_loc }}</td>
                <td>{{ org.delta_loc | default(0) }}</td>
                <td>{{ org.avg_loc_per_commit | format_loc }}</td>
                <td>{{ org.repositories_count | default(0) }}</td>
            </tr>
            {% endfor %}
        </tbody>
    </table>

</section>
{% endif %}
