def process_kns_committeesession(sessions):
     for session in rows_counter('kns_committeesession', sessions):
         committee_id = session['CommitteeID']
         session_date = session['StartDate'].date()
         attended_mk_ids = get_session_attended_mk_ids(
             session['CommitteeSessionID'])
         for mk_id, faction_id in get_mk_faction_ids(
                 all_mk_ids, mk_individual_factions, session_date):
             knessetdate = get_knessetdate(kns_knessetdates_sorted,
                                           session_date)
             if not knessetdate:
                 continue
             agg = aggregates.setdefault(knessetdate['knesset'], {})\
                             .setdefault(knessetdate['plenum'], {})\
                             .setdefault(knessetdate['assembly'], {})\
                             .setdefault(knessetdate['pagra'], {})\
                             .setdefault(committee_id, {})\
                             .setdefault(faction_id, {})\
                             .setdefault(mk_id, defaultdict(int))
             if mk_id in attended_mk_ids:
                 agg['attended_meetings'] += 1
             if session['parts_parsed_filename']:
                 agg['protocol_meetings'] += 1
             if session['TypeDesc'] == 'פתוחה':
                 agg['open_meetings'] += 1
 def process_kns_plenumsession(sessions):
     for session in rows_counter('kns_plenumsession', sessions):
         session_date = get_plenum_session_start_date(session)
         voted_mk_ids = get_session_voted_mk_ids(session['PlenumSessionID'])
         for mk_id, faction_id in get_mk_faction_ids(
                 all_mk_ids, mk_individual_factions, session_date):
             knessetdate = get_knessetdate(kns_knessetdates_sorted,
                                           session_date)
             agg = aggregates.setdefault(knessetdate['knesset'], {})\
                             .setdefault(knessetdate['plenum'], {})\
                             .setdefault(knessetdate['assembly'], {})\
                             .setdefault(knessetdate['pagra'], {})\
                             .setdefault(faction_id, {})\
                             .setdefault(mk_id, defaultdict(int))
             if mk_id in voted_mk_ids:
                 agg['voted_sessions'] += 1
             agg['total_sessions'] += 1
 def process_votes(votes):
     for vote in rows_counter('view_vote_rslts_hdr_approved', votes):
         vote_date = vote['vote_date']
         undisciplined_mk_ids, disciplined_mk_ids = get_vote_discipline_mk_ids(
             vote['id'])
         for mk_id, faction_id in get_mk_faction_ids(
                 all_mk_ids, mk_individual_factions, vote_date):
             knessetdate = get_knessetdate(kns_knessetdates_sorted,
                                           vote_date)
             agg = aggregates.setdefault(knessetdate['knesset'], {})\
                             .setdefault(knessetdate['plenum'], {})\
                             .setdefault(knessetdate['assembly'], {})\
                             .setdefault(knessetdate['pagra'], {})\
                             .setdefault(faction_id, {})\
                             .setdefault(mk_id, defaultdict(int))
             if mk_id in undisciplined_mk_ids:
                 agg['undisciplined_votes'] += 1
             elif mk_id in disciplined_mk_ids:
                 agg['disciplined_votes'] += 1
             agg['total_votes'] += 1
 def process_meeting_attendees(rows):
     for row in rows_counter('meeting_attendees', rows):
         session_attended_mk_ids[
             row['CommitteeSessionID']] = row['attended_mk_individual_ids']
 def process_session_voters(rows):
     for row in rows_counter('session_voters', rows):
         session_voted_mk_ids[row['PlenumSessionID']] = row['voter_mk_ids']