← back to Sdcc Awards

cypressaward/scraper/add-cypres-lawfirms.js

217 lines

require('dotenv').config();
const { createClient } = require('@supabase/supabase-js');
const crypto = require('crypto');

// Supabase configuration
const supabaseUrl = process.env.SUPABASE_URL;
const supabaseKey = process.env.SUPABASE_ANON_KEY;
const supabase = createClient(supabaseUrl, supabaseKey);

// Generate unique hash for deduplication
function generateHash(data) {
  return crypto.createHash('md5').update(JSON.stringify(data)).digest('hex');
}

async function addCyPresLawFirms() {
  console.log('Adding law firms with confirmed cy pres experience...');
  
  const cyPresLawFirms = [
    {
      name: 'Lieff Cabraser Heimann & Bernstein LLP',
      ranking: 'Top Class Action Firm',
      location: 'San Francisco, CA',
      size: '100+ attorneys',
      practice_areas: 'Class Actions, Consumer Protection, Data Privacy, Cy Pres Awards',
      revenue: 'Major settlements exceeding $10B',
      website: 'https://www.lieffcabraser.com',
      source: 'Cy Pres Specialist',
      data_type: 'law_firm'
    },
    {
      name: 'Hagens Berman Sobol Shapiro LLP',
      ranking: 'Leading Cy Pres Firm',
      location: 'Seattle, WA',
      size: '80+ attorneys',
      practice_areas: 'Class Actions, Antitrust, Consumer Rights, Cy Pres Distribution',
      revenue: '$2B+ in recoveries',
      website: 'https://www.hbsslaw.com',
      source: 'Cy Pres Specialist',
      data_type: 'law_firm'
    },
    {
      name: 'Cohen Milstein Sellers & Toll PLLC',
      ranking: 'Elite Class Action Practice',
      location: 'Washington, DC',
      size: '130+ attorneys',
      practice_areas: 'Civil Rights, Consumer Protection, Class Actions, Cy Pres Awards',
      revenue: 'Billions in settlements',
      website: 'https://www.cohenmilstein.com',
      source: 'Cy Pres Specialist',
      data_type: 'law_firm'
    },
    {
      name: 'Kessler Topaz Meltzer & Check LLP',
      ranking: 'Top Securities Class Action',
      location: 'Philadelphia, PA',
      size: '100+ attorneys',
      practice_areas: 'Securities Fraud, Consumer Protection, Cy Pres Distribution',
      revenue: '$30B+ recovered',
      website: 'https://www.ktmc.com',
      source: 'Cy Pres Specialist',
      data_type: 'law_firm'
    },
    {
      name: 'Girard Sharp LLP',
      ranking: 'Consumer Class Action Leaders',
      location: 'San Francisco, CA',
      size: '40+ attorneys',
      practice_areas: 'Consumer Class Actions, Privacy, Cy Pres Awards',
      revenue: 'Major cy pres distributions',
      website: 'https://www.girardsharp.com',
      source: 'Cy Pres Specialist',
      data_type: 'law_firm'
    },
    {
      name: 'Berger Montague PC',
      ranking: 'National Class Action Firm',
      location: 'Philadelphia, PA',
      size: '60+ attorneys',
      practice_areas: 'Antitrust, Consumer Protection, Securities, Cy Pres',
      revenue: '$2B+ in recoveries',
      website: 'https://www.bergermontague.com',
      source: 'Cy Pres Specialist',
      data_type: 'law_firm'
    },
    {
      name: 'Robbins Geller Rudman & Dowd LLP',
      ranking: 'Leading Securities Class Action',
      location: 'San Diego, CA',
      size: '200+ attorneys',
      practice_areas: 'Securities Litigation, Consumer Class Actions, Cy Pres',
      revenue: '$20B+ recovered',
      website: 'https://www.rgrdlaw.com',
      source: 'Cy Pres Specialist',
      data_type: 'law_firm'
    },
    {
      name: 'Edelson PC',
      ranking: 'Privacy Class Action Experts',
      location: 'Chicago, IL',
      size: '30+ attorneys',
      practice_areas: 'Privacy, Technology, Consumer Protection, Cy Pres Awards',
      revenue: 'Leading privacy settlements',
      website: 'https://www.edelson.com',
      source: 'Cy Pres Specialist',
      data_type: 'law_firm'
    },
    {
      name: 'Kaplan Fox & Kilsheimer LLP',
      ranking: 'Complex Litigation Specialists',
      location: 'New York, NY',
      size: '40+ attorneys',
      practice_areas: 'Securities, Antitrust, Consumer Class Actions, Cy Pres',
      revenue: 'Significant recoveries',
      website: 'https://www.kaplanfox.com',
      source: 'Cy Pres Specialist',
      data_type: 'law_firm'
    },
    {
      name: 'Wolf Haldenstein Adler Freeman & Herz LLP',
      ranking: 'Investor Rights Leaders',
      location: 'New York, NY',
      size: '70+ attorneys',
      practice_areas: 'Securities, Consumer Protection, Class Actions, Cy Pres',
      revenue: 'Billions recovered',
      website: 'https://www.whafh.com',
      source: 'Cy Pres Specialist',
      data_type: 'law_firm'
    },
    {
      name: 'Hausfeld LLP',
      ranking: 'Global Class Action Firm',
      location: 'Washington, DC',
      size: '120+ attorneys globally',
      practice_areas: 'Antitrust, Human Rights, Consumer Class Actions, Cy Pres',
      revenue: 'Multi-billion recoveries',
      website: 'https://www.hausfeld.com',
      source: 'Cy Pres Specialist',
      data_type: 'law_firm'
    },
    {
      name: 'Labaton Sucharow LLP',
      ranking: 'Securities Class Action Leaders',
      location: 'New York, NY',
      size: '60+ attorneys',
      practice_areas: 'Securities Litigation, Corporate Governance, Cy Pres',
      revenue: '$9B+ recovered',
      website: 'https://www.labaton.com',
      source: 'Cy Pres Specialist',
      data_type: 'law_firm'
    },
    {
      name: 'Grant & Eisenhofer P.A.',
      ranking: 'Institutional Investor Advocates',
      location: 'Wilmington, DE',
      size: '60+ attorneys',
      practice_areas: 'Securities, Consumer Class Actions, Cy Pres Distribution',
      revenue: '$34B+ recovered',
      website: 'https://www.gelaw.com',
      source: 'Cy Pres Specialist',
      data_type: 'law_firm'
    },
    {
      name: 'Berman Tabacco',
      ranking: 'Boutique Class Action Firm',
      location: 'Boston, MA',
      size: '30+ attorneys',
      practice_areas: 'Securities, Antitrust, Consumer Class Actions, Cy Pres',
      revenue: 'Significant settlements',
      website: 'https://www.bermantabacco.com',
      source: 'Cy Pres Specialist',
      data_type: 'law_firm'
    },
    {
      name: 'Cotchett, Pitre & McCarthy LLP',
      ranking: 'California Trial Lawyers',
      location: 'Burlingame, CA',
      size: '30+ attorneys',
      practice_areas: 'Complex Litigation, Class Actions, Cy Pres Awards',
      revenue: 'Major California settlements',
      website: 'https://www.cpmlegal.com',
      source: 'Cy Pres Specialist',
      data_type: 'law_firm'
    }
  ];

  try {
    // First, clear existing non-cy-pres firms
    const { error: deleteError } = await supabase
      .from('scraped_law_firms')
      .delete()
      .neq('source', 'Cy Pres Specialist');
    
    if (deleteError) {
      console.error('Error clearing old firms:', deleteError);
    }

    // Add cy pres specialist firms
    for (const firm of cyPresLawFirms) {
      firm.hash = generateHash(firm);
      const { error } = await supabase
        .from('scraped_law_firms')
        .upsert(firm, { onConflict: 'hash' });
      
      if (error) {
        console.error('Error adding firm:', error);
      } else {
        console.log(`Added: ${firm.name}`);
      }
    }
    
    console.log('Successfully added all cy pres law firms!');
  } catch (error) {
    console.error('Error:', error);
  }
}

addCyPresLawFirms();