forgeplus/lib/tasks/total_project_code_row.rake

51 lines
9.1 KiB
Ruby

namespace :total_project_code_row do
desc "total_project_code_row"
task done: :environment do
project_ids = ENV['ids'] || "2765,1403432,847,2,1404158,3688,1400803,1407390,6059,1428545,1446955,1405673,3984,1445122,1407391,1430163,1443757,1445075,1829,1451715,1405861,1453625,1448899,1447067,1446012,1407476,1430148,1449348,1403739,1406453,1407230,1448898,1401772,1450797,1406764,1405672,1445536,1407387,1450613,1446403,1451737,1450647,1443810,1448874,1444591,1402039,1451902,1451117,1451224,6225,1451109,1446077,1403195,1451811,1403502,1444608,1429980,1444226,1400977,1450500,1447064,2693,1403199,1407777,1430105,843,2604,3381,4851,1453757,1406540,1444158,1404145,1444520,1405245,1451898,1407686,1400819,1406723,1443180,1444040,1405941,1449043,17,1407294,1429714,1444604,1405509,1401026,1444774,1406315,1446653,1406393,1403060,6025,1403196,1443760,1429995,1405366,1407122,1449355,1448904,1452104,1407611,1443942,1401981,1406278,1455042,1449518,1406135,1443270,941,1406316,6079,1428739,1452508,1406851,1443482,1401728,1445116,1429423,1452103,1451644,1452906,1406128,1403784,6319,1449378,1451188,1444562,3336,1446002,1406034,1445001,1451314,1428488,1405742,1449315,1401708,1405402,1443187,1401062,1455043,1405826,1450017,1406279,1405103,1405999,1406959,1406484,1405738,1454501,1453645,1724,5732,1406335,1443793,1447650,1448936,1451233,1451126,1443128,1448629,1403646,1444752,1406258,1449349,1406513,1448178,1405769,1443181,1448290,1428758,1455046,1403197,1445822,1405379,1447249,1428476,1445650,1447632,1429330,1449763,3259,1445985,1456619,1406623,1455494,1449654,1407633,1444985,1450218,1406325,1448992,1454234,1453001,1429541,1448665,1402709,1453579,1405468,1449500,1455557,1450710,1444068,1406336,1405244,1449120,1428714,1449920,1454096,4820,1449316,1406870,1406177,1446191,1405603,1406178,1445933,1452634,1406204,1452325,1405095,1447667,1449033,1453943,1452549,1453578,1444565,1448694,1449531,1405718,1454658,1404870,1407055,1448483,1451274,1451574,1447529,1405251,1452463,1406348,1447873,1405621,1445711,1450024,1450611,1405360,1428643,1447690,1404262,1446036,1449070,1446938,1430178,1443022,1446886,1450588,1453433,1443867,1448108,1406852,1448714,1452652,1406203,1406347,1444701,1453838,1406062,1406196,1449932,1449965,1452757,1406209,1430220,1445953,1403329,1447645,1454256,1446121,1450507,3986,1406875,299,2688,3889,5478,5522,1406206,1443970,1446188,1451119,1451348,1444282,1401724,1406319,1406814,1405814,5479,1406205,1443473,1448902,1447771,1430053,1444767,1446246,1451822,1451875,1443371,1429935,1404707,1405209,1451133,1406320,1446186,1446981,1406239,1443471,1451490,1455864,1406208,1403354,1406736,1445629,1450790,1444059,1452676,1451921,1405837,1448827,1450228,1407545,1446963,1405636,1444704,1445649,1446635,1451740,1430179,1446140,1448509,1443428,1452487,1403198,1436620,1449757,1456977,1407190,1446582,1447727,1407045,1444567,1443367,1448015,1450646,1450674,1444393,1447005,1400804,1407665,1430010,1430121,1430248,1444997,1448565,1405700,1443788,1446190,1450924,1406860,1451977,1453392,1456685,1406318,1407435,1410257,1428541,1403817,1407438,1446148,1450843,1453771,1405191,1450768,1449279,1450650,1444595,1446371,1443283,1456712,315,862,953,1734,2147,2188,2271,2635,3291,3430,3432,3995,4418,4556,5200,5294,5340,5536,5689,6065,1404839,1404585,1407645,1445817,1447672,1453050,1456633,1450550,1448320,1450583,1451091,1450020,1456721,1445813,1452611,1446378,1451727,1453708,1406100,1399224,1429936,1445655,1447800,1452131,1454027,1454439,1442938,1444218,1445011,1452241,1407695,1407169,1446233,1447615,1454600,1405976,1447624,1445771,1445774,1452079,1406114,1449089,1452792,1403200,1403678,1450195,1429959,1455205,1406015,1429968,1448325,1407296,1443207,1452942,1453259,1401270,1449985,1450889,1454112,1450903,3725,1403786,1443815,1406761,1447073,1450434,1446786,1447747,1448901,1404772,1446373,1449726,1450553,1450715,1404204,1430164,1443458,1448288,1452727,1405832,1429054,1444772,1448573,1451005,1429050,1406864,1443266,1444015,1448075,1448973,1450753,1444615,1449774,1450728,1451365,1455000,1405848,1407838,1446099,1453788,1405748,1407494,1444130,1453423,1453715,1401006,1406596,1446690,1449951,5988,1407198,1447772,1449429,1449596,1451095,1407233,1429884,1445598,1446793,1449964,1428447,1447072,1447204,1447799,1401310,1443508,1444513,1444601,1445752,1447205,1448640,1452242,1452819,1454619,1454869,1428625,1447520,1450088,1451370,1428720,1429821,1443247,1445751,1450895,1451074,1404344,1429094,1443809,1450432,1450585,1450829,1451250,1453987,1455269,1405303,1407362,1444497,1449986,1451781,5977,6465,1428487,1443213,1444554,1446571,1448563,1450736,1451023,1452720,1402083,1405097,1443910,1446137,1452001,1456296,1406766,1445409,1447340,1447551,1450805,1452574,1455863,1405096,1429427,1429982,1444451,1444943,1448283,1449368,1449602,1450265,1450987,1454420,1429302,1444627,1449590,1449871,1450424,1453256,1403917,1407685,1428786,1445872,1447450,1447759,1450280,1451273,1453273,1453800,29,290,781,832,880,954,956,957,977,982,1042,1287,1450,1476,1540,1635,1707,1736,1791,1813,2090,2107,2143,2160,2174,2198,2245,2354,2372,2443,2541,2542,2543,2559,2691,2699,2804,2806,2958,2988,3091,3234,3330,3428,3435,3436,3437,3450,3482,3633,3894,3905,3906,3989,4004,4014,4569,4574,4599,4608,4609,4627,4628,5022,5199,5202,5344,5354,5391,5395,5399,5492,5499,5553,5589,5592,5717,5722,5793,5931,6014,6018,6036,6064,1407474,1443844,1443890,1444467,1445942,1447071,1448081,1448326,1449756,1451951,467,1305,1745,1407660,1443474,1444067,1444157,1445825,1447679,1448179,1455434,1456670,1404593,1428822,1444283,1447896,1450127,1450551,1450978,1451157,1452927,1453582,1454352,5787,6021,1400757,1404796,1428868,1444152,1447019,1450169,1451171,1451392,1453233,1408,1565,2969,4552,1403688,1403823,1406495,1406869,1428627,1443005,1446241,1447245,1447736,1448064,1448900,1450378,1451303,1451422,1452244,1453600,2406,3328,3368,3942,5605,1403351,1404334,1404464,1405713,1428523,1428841,1445539,1446762,1449367,1453514,1328,2353,5027,5476,5879,1428733,1429107,1429406,1443146,1443442,1444848,1445745,1448872,1450291,1451257,1454662,2319,4403,4625,5242,1402182,1403724,1406088,1407257,1407859,1444618,1446806,1447387,1447819,1449775,1450121,1450214,1450544,1453790,1453934,3256,1404962,1406028,1430133,1436628,1444060,1445799,1446227,1450059,1450515,1450587,1453868,1454090,1455183,1455224,482,1401710,1402994,1405744,1407350,1428824,1443953,1444450,1444842,1446105,1447695,1448480,1448893,1450642,1450851,1453241,1455274,1754,3882,5355,1400773,1406115,1407277,1407480,1407872,1429888,1443115,1443434,1446087,1450901,1451489,1453549,1454223,1455074,1455235,1170,1737,5343,1405025,1444211,1445708,1449104,1449310,1450268,1450445,1451054,1451683,1451790,1452411,1454114,2760,5447,5784,1406292,1406853,1429156,1444039,1445399,1447295,1447588,1448906,1449064,1450526,1451281,1453565,1454982,1456284,2370,2393,4564,4776,1405104,1405427,1407445,1443125,1445556,1446182,1448723,1448903,1449226,1450915,1452404,1456300,3439,1402082,1406044,1406137,1407298,1410241,1429083,1430136,1443422,1449766,1451317,1452732,1454402,1456463,1456602,5915,1404470,1406349,1428688,1445691,1447352,1448574,1448751,1449191,1450547,1451100,1453562,1454336,2749,3082,3816,3993,4600,5601,1403855,1405675,1406620,1429467,1429890,1445664,1445962,1447909,1449252,1450969,1451293,1451313,1451782,1453105,1453928,1454787,1455002,1455014,1456561,4535,5037,1405403,1405698,1406507,1406701,1407436,1407674,1429195,1443831,1444267,1445954,1446154,1446579,1447557,1447591,1448082,1448123,1449239,1449308,1450401,1450431,1450879,1450907,1450977,1451829,1451830,1452038,1453007,1454661,1456676,291"
puts "project_ids=================#{project_ids}"
projects = Project.where(id: project_ids.split(","))
if ENV['count'].present?
projects = projects.limit(ENV['count'].to_i)
end
has_project_ids = ProjectExt.pluck(:project_id)
projects = projects.where.not(id: has_project_ids)
file_path = "#{Rails.root}/files/total-tmp"
FileUtils.mkdir_p(file_path)
@date_count_hash = {}
# projects = Project.where(:name => 'opensource0311')
projects.each_with_index do |project, index|
puts "begin total===#{index}"
# domain = "https://gitlink.org.cn"
domain = "http://10.9.117.109:3000"
repo_url = "#{domain}/#{project.owner.name}/#{project.identifier}.git"
project_path = "#{file_path}/#{project.owner.name}-#{project.identifier}"
system "git clone -b #{project.default_branch} --depth 1 #{repo_url} #{project_path}"
total_row = `cd #{project_path} && git ls-files | xargs wc 2>/dev/null -l | awk '{print $1 }'| tail -n 1`
project_ext = ProjectExt.find_or_initialize_by(project_id: project.id)
project_ext.row = total_row
project_ext.save
# sleep 1.seconds
FileUtils.rm_rf("#{project_path}")
end
end
task test: :environment do
file_path = "#{Rails.root}/files/total-tmp"
FileUtils.mkdir_p(file_path)
domain = "https://gitlink.org.cn"
repo_url = "#{domain}/gitlink/forgeplus.git"
project_path = "#{file_path}/gitlink-forgeplus"
system "git clone --depth 1 #{repo_url} #{project_path}"
total_row = `cd #{project_path} && git ls-files | xargs wc 2>/dev/null -l | awk '{print $1 }'| tail -n 1`
puts "total_rown===#{total_row}"
# sleep 1.seconds
FileUtils.rm_rf("#{project_path}")
end
end