@@ -972,6 +972,52 @@ defmodule AlgoraWeb.Org.JobLive do
972972 </ . button >
973973 </ div >
974974
975+ < div class = "mt-4 space-y-2 text-sm " >
976+ <%= if @ heatmap_data do %>
977+ < div class = "flex items-center gap-2 " >
978+ < . icon
979+ name = {
980+ if get_avg_daily_commits ( @ heatmap_data ) >= 1 , do: "tabler-check" , else: "tabler-x"
981+ }
982+ class = {
983+ if get_avg_daily_commits ( @ heatmap_data ) >= 1 ,
984+ do: "text-success-400" ,
985+ else: "text-destructive"
986+ }
987+ />
988+ < span > { get_avg_daily_commits ( @ heatmap_data ) } commits per day</ span >
989+ </ div >
990+ < div class = "flex items-center gap-2 " >
991+ < . icon
992+ name = {
993+ if get_weekend_commits ( @ heatmap_data ) >= 1 , do: "tabler-check" , else: "tabler-x"
994+ }
995+ class = {
996+ if get_weekend_commits ( @ heatmap_data ) >= 1 ,
997+ do: "text-success-400" ,
998+ else: "text-destructive"
999+ }
1000+ />
1001+ < span > Active on weekends</ span >
1002+ </ div >
1003+ < div class = "flex items-center gap-2 " >
1004+ < . icon
1005+ name = {
1006+ if has_matching_tech_stack? ( @ user . tech_stack , @ tech_stack , @ contributions ) ,
1007+ do: "tabler-check" ,
1008+ else: "tabler-x"
1009+ }
1010+ class = {
1011+ if has_matching_tech_stack? ( @ user . tech_stack , @ tech_stack , @ contributions ) ,
1012+ do: "text-success-400" ,
1013+ else: "text-destructive"
1014+ }
1015+ />
1016+ < span > Versed in { Enum . join ( @ tech_stack , ", " ) } </ span >
1017+ </ div >
1018+ <% end %>
1019+ </ div >
1020+
9751021 < . heatmap_display :if = { @ heatmap_data } heatmap_data = { @ heatmap_data } />
9761022
9771023 < div :if = { @ contributions != [ ] } class = "mt-4 " >
@@ -1685,4 +1731,51 @@ defmodule AlgoraWeb.Org.JobLive do
16851731 end
16861732
16871733 def price , do: Algora.Settings . get_subscription_price ( )
1734+
1735+ defp get_avg_daily_commits ( heatmap_data ) do
1736+ total_contributions = get_in ( heatmap_data , [ "totalContributions" ] ) || 0
1737+ days = length ( get_in ( heatmap_data , [ "weeks" ] ) || [ ] ) * 7
1738+ days = if days > 0 , do: days , else: 365
1739+ Float . round ( total_contributions / days , 1 )
1740+ end
1741+
1742+ defp get_weekend_commits ( heatmap_data ) do
1743+ weeks = get_in ( heatmap_data , [ "weeks" ] ) || [ ]
1744+
1745+ weekend_days =
1746+ Enum . flat_map ( weeks , fn week ->
1747+ days = week [ "contributionDays" ] || [ ]
1748+
1749+ Enum . filter ( days , fn day ->
1750+ date = Date . from_iso8601! ( String . replace ( day [ "date" ] , "T00:00:00.000+00:00" , "" ) )
1751+ # Saturday and Sunday
1752+ Date . day_of_week ( date ) in [ 6 , 7 ]
1753+ end )
1754+ end )
1755+
1756+ total_weekend_contributions = Enum . sum ( Enum . map ( weekend_days , & & 1 [ "contributionCount" ] ) )
1757+ total_weekends = length ( weekend_days )
1758+ # ~52 weeks * 2 days
1759+ total_weekends = if total_weekends > 0 , do: total_weekends , else: 104
1760+ Float . round ( total_weekend_contributions / total_weekends , 1 )
1761+ end
1762+
1763+ defp has_matching_tech_stack? ( user_stack , job_stack , contributions ) do
1764+ # Get tech stacks from top contributions
1765+ contribution_techs =
1766+ contributions
1767+ |> Enum . flat_map ( fn contribution ->
1768+ contribution . repository . tech_stack || [ ]
1769+ end )
1770+ |> Enum . uniq ( )
1771+
1772+ # Combine user's declared tech stack with contribution tech stacks
1773+ all_user_techs =
1774+ ( ( user_stack || [ ] ) ++ contribution_techs )
1775+ |> Enum . uniq ( )
1776+ |> MapSet . new ( & String . downcase / 1 )
1777+
1778+ job_set = MapSet . new ( Enum . map ( job_stack || [ ] , & String . downcase / 1 ) )
1779+ ! MapSet . disjoint? ( all_user_techs , job_set )
1780+ end
16881781end
0 commit comments