<commit_before>import { CountryRecord, SubdivisionsRecord } from '@maxmind/geoip2-node';
import { findCityByIp } from '../db/maxmind/city';

import { ipToNumber, numberToIp } from '../ip-utils';

export {
  ipToNumber,
  numberToIp,
};

type IpCountry = {
  ip: number;
  country_name: string;
  subdivision_1_name: string;
}

/**
 * Given a collection of IP addresses returns the country associated with each one.
 * @param ips - numeric IP addresses
 */
export const getCityLocationsByIp = async (ips: number[]): Promise<IpCountry[]> => {
  const promises = ips.map(async (ip) => {
    const ipAddress = numberToIp(ip);
    const city = await findCityByIp(ipAddress);
    const country_name = (city.country as CountryRecord).names?.en ?? 'unknown';
    const subdivisions = (city.subdivisions || []) as SubdivisionsRecord[];<commit_msg>Remove two more TS casts<commit_after>import { findCityByIp } from '../db/maxmind/city';

import { ipToNumber, numberToIp } from '../ip-utils';

export {
  ipToNumber,
  numberToIp,
};

type IpCountry = {
  ip: number;
  country_name: string;
  subdivision_1_name: string;
}

/**
 * Given a collection of IP addresses returns the country associated with each one.
 * @param ips - numeric IP addresses
 */
export const getCityLocationsByIp = async (ips: number[]): Promise<IpCountry[]> => {
  const promises = ips.map(async (ip) => {
    const ipAddress = numberToIp(ip);
    const city = await findCityByIp(ipAddress);
    const country_name = city.country?.names?.en ?? 'unknown';
    const subdivisions = city.subdivisions || [];
{'fraction_non_alphanumeric': 0.13001912045889102, 'fraction_numerical': 0.0019120458891013384, 'mean_word_length': 4.198675496688741, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7010261', 'n_tokens_mistral': 495, 'n_tokens_neox': 483, 'n_words': 138}