Computer

Masimo Sues US Customs Over Apple Watch Blood Oxygen Workaround

Slashdot - Thu, 2025-08-21 02:45
Last week, following a recent U.S. Customs ruling, Apple reintroduced blood oxygen monitoring to certain Apple Watch models in the U.S., sidestepping an ITC import ban stemming from its legal dispute with medical device maker Masimo. Today, Masimo fired back with a new lawsuit against the U.S. Customs and Border Protection. 9to5Mac reports: The company says US Customs and Border Protection (CBP) overstepped its authority and violated due process when it reversed its earlier decision on August 1 and allowed Apple to restore the feature. Moreover, Masimo says it found out about the decision when Apple publicly announced the return of the feature: "It has now come to light that CBP thereafter reversed itself without any meaningful justification, without any material change in circumstances, and without any notice to Masimo, let alone an opportunity for Masimo to be heard. CBP changed its position on Apple's watch-plus-iPhone redesign through an ex parte proceeding. Specifically, on August 1, 2025, CBP issued an 3 ex parte ruling permitting Apple to import devices that, when used with iPhones already in the United States, perform the same functionality that the ITC found to infringe Masimo's patents. Masimo only discovered this ruling on Thursday, August 14, 2025, when Apple publicly announced it would be reintroducing the pulse oximetry functionality through a software update." The company is now asking the court for a temporary restraining order and preliminary injunction to block the CBP's decision, and reinstate the original ruling that "determined that Apple's redesigned watches could be imported only to the extent the infringing functionality was completely disabled." As reported by Bloomberg Law, Masimo says the following in its supporting brief: "Each passing day that this unlawful ruling remains in effect irreparably deprives Masimo of its right to be free from unfair trade practices and to preserve its competitive standing in the U.S. marketplace." Masimo further argues that CBP's move "effectively nullified" the ITC's exclusion order against Apple. Apple's appeal of that ban is still pending before the Federal Circuit.

Read more of this story at Slashdot.

Categories: Computer, News

Oregon Man Accused of Operating One of Most Powerful Attack 'Botnets' Ever Seen

Slashdot - Thu, 2025-08-21 02:02
A 22-year-old Oregon man has been charged with operating one of the most powerful botnets ever recorded. The network, known as Rapper Bot, launched over 370,000 DDoS attacks worldwide, including against X, DeepSeek, U.S. tech firms, and even Defense Department systems. It was allegedly operated by Ethan Foltz of Eugene, Oregon. The Wall Street Journal reports: Foltz faces a maximum of 10 years in prison on a charge of abetting computer intrusions, the Justice Department said in a news release. Rapper Bot was made up of tens of thousands of hacked devices and was capable of flooding victims' websites with enough junk internet traffic to knock them offline, an attack known as a distributed denial of service, or DDoS. In February, the networking company Nokia measured a Rapper Bot attack against a gaming platform at 6.5 trillion bits per second, well above the several hundred million bits a second of the average high-speed internet connection. "This would place Rapper Bot among the most powerful DDoS botnets to have ever existed," said a criminal complaint that the prosecutors filed Tuesday in a federal court in Alaska. Investigators said Rapper Bot's attacks were so powerful that they were able to overwhelm all but the most robust networks. Foltz allegedly rented out Rapper Bot to paying customers, including gambling website operators who would use the network in extortion attempts, according to the complaint. The botnet was used to launch more than 370,000 attacks in 80 countries, including China, Japan and the U.S., prosecutors said. It launched its attacks from hacked routers, digital video recorders and cameras, not from computers. [...] "At its height, it mobilized tens of thousands of devices, many with no prior role in DDoS," said Jerome Meyer, a researcher with Nokia's Deepfield network-analysis division. "Taking it down removes a major source of the largest attacks we see."

Read more of this story at Slashdot.

Categories: Computer, News

Google's Pixel Watch 4 Has a Big Focus On AI

Slashdot - Thu, 2025-08-21 01:20
An anonymous reader quotes a report from The Verge's Victoria Song: The original Pixel Watch was late to the game. For years, there had been rumors of a Google smartwatch that never materialized. Then, when it finally arrived, it was a quintessential first-gen device, with thicc bezels, dismal battery life, and a host of quirks that needed ironing out. My DMs were full of people wondering when the watch would be unceremoniously dumped into Google's infamous product graveyard. A part of me wondered if Google was going to spend the next decade playing catch-up. Fast forward to 2025, and I'm holding the Pixel Watch 4 at Google's office in New York City. On the surface (and my wrist), it doesn't look like much has changed. But after fiddling with a few menus, watching some demos, and talking over the updates, it's evident that Google has a clear vision about where smartwatches are going. [...] Starting with hardware, the Pixel Watch 4 has a new domed "Actua 360" display -- as in, the display itself, not just the glass, is also domed. What this translates to is about 10 percent more visible screen space, 15 percent thinner bezels, and a 50 percent increase in maximum brightness to 3,000 nits. On a table, there's a lineup of the Pixel Watch 2, 3, and 4 with the flashlight app turned on. Side-by-side, the improvements are striking. Material 3 Expressive in Wear OS 6also helps emphasize the Pixel Watch's roundness. (No squircles here, folks.) The widgets have more rounded edges, and each screen has been redesigned to be more glanceable, fitting more complications. It's not Liquid Glass, but there are subtle animations when flitting through menus that call your attention to the Pixel Watch's rain droplet-inspired design. Altogether, it's a design tweak that makes senseandis aesthetically pleasing. Google also says battery life has improved. The 41mm watch gets an estimated 30 hours on a single charge, while the 45mm gets 40 hours. That can stretch up to two days in battery saver mode for the smaller watch and three days for the larger one. I couldn't test that at a hands-on, but I did get to see the improved fast charging in action. As with theGalaxy Watch 8, Gemini has a big presence on the Pixel Watch 4. It replaces Google Assistant and is capable of more complex queries -- even if none have been able to blow my mind yet. But, in a bid to make interacting with Gemini as smooth as possible, the speaker and haptic engines have also been updated so you can hear and interact more easily. There's also a new raise-to-talk gesture that lets you speak to Gemini without having to use the wake word. The processor has been upgraded to the Snapdragon W5 Gen 2 to enable more on-device AI features, as well, like smart replies. On the Pixel Watch 4, you'll get more smart reply options to texts that refer to the content of your conversations. They're not confined to the default Messages app, either. But the major AI update this time around is a Gemini-powered health coach that's slated to arrive alongside a revamped Fitbit app in October. ... The gist is the health coach will act more like a personal trainer than a Captain Obvious summary generator. If you sleep poorly, it'll adjust workout suggestions. (This is also why Google is also introducing an improved sleep algorithm.) You can tell it that you've been injured, and that too will be taken into consideration when generating weekly fitness plans. [...] Another big first is the Satellite SOS mode. If you're without your phone and in a remote area with no signal, you can still call emergency services. (So long as you have the LTE version of the watch.) The big thing here is that there's no extra subscription cost. The watch will also feature more accurate dual-frequency GPS -- a nice update given that I've had issues with the Pixel Watch's GPS maps in the past. The Pixel Watch 4 is priced at $349.99 and is available for pre-order now.

Read more of this story at Slashdot.

Categories: Computer, News

Harvard Dropouts To Launch 'Always On' AI Smart Glasses That Listen, Record Every Conversation

Slashdot - Thu, 2025-08-21 00:40
Two Harvard dropouts are launching Halo X, a $249 pair of AI-powered smart glasses that continuously listen, record, and transcribe conversations while displaying real-time information to the wearer. "Our goal is to make glasses that make you super intelligent the moment you put them on," said AnhPhu Nguyen, co-founder of Halo. Co-founder Caine Ardayfio said the glasses "give you infinite memory." "The AI listens to every conversation you have and uses that knowledge to tell you what to say ... kinda like IRL Cluely," Ardayfio told TechCrunch. "If somebody says a complex word or asks you a question, like, 'What's 37 to the third power?' or something like that, then it'll pop up on the glasses." From the report: Ardayfio and Nguyen have raised $1 million to develop the glasses, led by Pillar VC, with support from Soma Capital, Village Global, and Morningside Venture. The glasses will be priced at $249 and will be available for preorder starting Wednesday. Ardayfio called the glasses "the first real step towards vibe thinking." The two Ivy League dropouts, who have since moved into their own version of the Hacker Hostel in the San Francisco Bay Area, recently caused a stir after developing a facial-recognition app for Meta's smart Ray-Ban glasses to prove that the tech could be used to dox people. As a potential early competitor to Meta's smart glasses, Ardayfio said Meta, given its history of security and privacy scandals, had to rein in its product in ways that Halo can ultimately capitalize on. [...] For now, Halo X glasses only have a display and a microphone, but no camera, although the two are exploring the possibility of adding it to a future model. Users still need to have their smartphones handy to help power the glasses and get "real time info prompts and answers to questions," per Nguyen. The glasses, which are manufactured by another company that the startup didn't name, are tethered to an accompanying app on the owner's phone, where the glasses essentially outsource the computing since they don't have enough power to do it on the device itself. Under the hood, the smart glasses use Google's Gemini and Perplexity as its chatbot engine, according to the two co-founders. Gemini is better for math and reasoning, whereas they use Perplexity to scrape the internet, they said.

Read more of this story at Slashdot.

Categories: Computer, News

Trump Confirms US Is Seeking 10% Stake In Intel

Slashdot - Thu, 2025-08-21 00:02
An anonymous reader quotes a report from Ars Technica: After the Trump administration confirmed a rumor that the US is planning to buy a 10 percent stake in Intel, US Senator Bernie Sanders (I-Vt.) came forward Wednesday to voice support for the highly unusual plan, finding rare common ground with Donald Trump. According to Commerce Secretary Howard Lutnick, the plan would see the US disbursing approved CHIPS Act grants only after acquiring non-voting shares of Intel and likely other chipmakers. That would allow the US to profit off its investment in chipmakers, Lutnick suggested, and Sanders told Reuters that he agreed American taxpayers could benefit from the potential deals. "If microchip companies make a profit from the generous grants they receive from the federal government, the taxpayers of America have a right to a reasonable return on that investment," Sanders said. While Lutnick gave Trump credit for coming up with what White House Press Secretary Karoline Leavitt described as a "creative idea that has never been done before" to protect US national and economic security, it appears that Lutnick is driving the initiative. "Lutnick has been pushing the equity idea," insiders granted anonymity previously told Reuters, "adding that Trump likes the idea." So far, Intel has engaged in talks, while the Taiwan Semiconductor Manufacturing Company (TSMC) and other major CHIPS grant recipients like Samsung and Micron have yet to comment on the potential arrangement the Trump administration seems likely to pursue. They may possibly risk clawbacks of grants if such deals aren't made. On Wednesday, Taiwan Economy Minister Kuo Jyh-huei said his ministry would be consulting with TSMC soon, while noting that as yet, it's hard to "thoroughly understand the underlying meaning" of Lutnick's public comments. So far, Lutnick has only specified that "any potential arrangement wouldn't provide the government with voting or governance rights in Intel," dispelling fears that the US would use its ownership stake to try to control the world's most important chipmakers. Further reading: Intel is Getting a $2 Billion Investment From SoftBank

Read more of this story at Slashdot.

Categories: Computer, News

Gemini For Home Is Google's Biggest Smart Home Play In Years

Slashdot - Wed, 2025-08-20 23:25
Google announced Gemini for Home, a new AI-powered voice assistant that will replace Google Assistant on Nest smart speakers and displays starting in October. Powered by Gemini's advanced reasoning and conversational capabilities, it promises more natural interactions, complex task handling, and features like Gemini Live for back-and-forth conversations. The Verge reports: According to a blog post by Anish Kattukaran, chief product officer of Google Home and Nest, using Gemini for Home will "feel fundamentally new." He says the new voice assistant leverages the "advanced reasoning, inference and search capabilities" of Google's AI models, along with adaptations for the home that allow for more natural interactions to complete more complex tasks. In short, it should be an assistant that can better understand context, nuance, and intention -- a complete change from its predecessor. For example, Kattukaran says Gemini for Home can accurately respond to requests like "turn off the lights everywhere except my bedroom," "play that song from this year's summer blockbuster about race cars," or "set a timer for perfectly blanched broccoli." It will also create lists, calendar entries, and reminders more easily than before, he says. Another big upgrade is that Gemini Live will be part of Gemini for Home, bringing more conversational back-and-forth voice interactions to Google Home without needing to repeatedly say "Hey Google." Kattukaran says this will allow for more detailed and personalized help -- from cooking ("I have spinach, eggs, cream cheese, and smoked salmon in the fridge. Help me make a delicious meal") to brainstorming how to buy a new car or figuring out how to fix your dishwasher, as well as more creative tasks like generating bedtime stories. [...] Google hasn't announced pricing for the paid tier of Gemini for Home, but Gemini Live, with its more advanced capabilities, is a likely candidate for a premium plan.

Read more of this story at Slashdot.

Categories: Computer, News

Amazon Looks To Ditch Homegrown Software For Android in Fire Tablet Revamp

Slashdot - Wed, 2025-08-20 22:44
Amazon is plotting a big change to its Fire tablet lineup following years of escalating gripes from consumers and app developers over the company's homegrown operating system. Reuters: As part of a project known internally as Kittyhawk, Amazon plans to release a higher-end tablet as soon as next year offering the Android operating system software for the first time, according to six people familiar with the matter. Since the Fire tablet's introduction in 2011, Amazon has used what is known as a "forked" version of Android with custom modifications that make it work like a unique operating system. [...] The first Amazon Android tablet, slated for next year, will be pricier than current models, the people said. One of them said Amazon had discussed a $400 price tag, nearly double the cost of its current higher-end $230 Fire Max 11 tablet. IPads, by comparison, range from $350 to $1,200. Reuters could not learn additional specifications for the planned Amazon tablet, such as screen size and speaker quality or memory capacity. Amazon historically has avoided using software or other products from third parties, preferring to develop the services in-house or, barring that, to acquire a competitor.

Read more of this story at Slashdot.

Categories: Computer, News

UAE Adds Newborns To Major Genome Project

Slashdot - Wed, 2025-08-20 22:05
Abu Dhabi is gathering the DNA of Emirati newborns in a significant expansion of a national genomic sequencing project that aims to put the UAE on the cutting-edge of health care. From a report: The UAE capital has so far mapped the genomes of 68% of Emirati citizens, a spokesperson for M42, the firm running the program, told Semafor, while at-birth sequencing is being offered to parents on a voluntary basis across several hospitals, and aims to detect over 800 treatable childhood genetic conditions. Only around 1% of the world's mapped genomes are of Arab descent. The UAE is looking to address the gap while tackling public health issues and expanding personalized health care offerings.

Read more of this story at Slashdot.

Categories: Computer, News

Microsoft Readies Big Feature Updates For Next Month and Beyond

Slashdot - Wed, 2025-08-20 21:25
Windows 11 users will receive significant UI refinements and AI improvements starting next month as Microsoft prepares its September feature drop followed by additional updates through fall. The update, Windows Central reports, will bring customizable lock screen widgets globally after months of European exclusivity, photo grid views in Windows Search, and a redesigned Windows Hello authentication interface. Copilot+ PCs will gain a revamped Recall application with workflow suggestions and File Explorer AI integration through Click To Do. October and November releases will introduce a larger, customizable Start menu allowing removal of the Recommended section and expanded dark mode support for legacy File Explorer dialogs.

Read more of this story at Slashdot.

Categories: Computer, News

Chinese 'Virtual Human' Salespeople Are Outperforming Their Real Human Counterparts

Slashdot - Wed, 2025-08-20 20:45
AI-powered salespeople are outperforming their human counterparts on Chinese e-commerce platforms, working around the clock without fatigue to sell products ranging from printers to wet wipes. Shanghai marketing firm PLTFRM has deployed 30 virtual avatars across Taobao and Pinduoduo using Baidu video models and DeepSeek language models. Brother's AI avatar generated $2,500 in printer sales within two hours and increased livestream revenue 30 percent. The company now checks overnight AI sales data each morning as routine. Livestreaming drives over one-third of China's e-commerce sales, with half the population shopping via broadcast in 2024. Baidu's June livestream featuring an AI version of influencer Luo Yonghao drew 13 million views and generated $7.7 million in sales. American and European companies have expressed interest, Wired reports, after PLTFRM successfully tested English-language avatars on YouTube, TikTok, and Facebook.

Read more of this story at Slashdot.

Categories: Computer, News

FTC Sues LA Fitness For Making it Difficult for Consumers To Cancel Gym Memberships

Slashdot - Wed, 2025-08-20 20:00
FTC, in a press release Wednesday: The Federal Trade Commission today sued the operators of LA Fitness and other gyms over allegations they make it exceedingly difficult for consumers to cancel their gym memberships and related services that continued indefinitely unless cancelled. The agency is seeking a court order prohibiting the allegedly unfair conduct and money back for consumers harmed by the difficulty in cancelling memberships. "The FTC's complaint describes a scenario that too many Americans have experienced -- a gym membership that seems impossible to cancel," said Christopher Mufarrige, Director of the Bureau of Consumer Protection. "Tens of thousands of LA Fitness customers reported difficulties -- cancellation was often restricted to specific times or required speaking to specific managers who were often not present or available. The FTC will not hesitate to act on behalf of consumers when it believes companies are stifling consumers' ability to choose which recurring charges they want to keep."

Read more of this story at Slashdot.

Categories: Computer, News

India Seeks Ban on Online Betting Apps To Curb Addiction

Slashdot - Wed, 2025-08-20 19:25
India has moved a legislation to ban online money gaming due to rising instances of addiction, money laundering and financial frauds through these apps. From a report: A bill passed in the lower house of Parliament on Wednesday seeks to prohibit promotion and operation of gaming apps that require users to pay money for the chance to win cash. The move threatens India's $3.8 billion gaming industry that has drawn global investors and also fostered homegrown fantasy sports betting apps such as Dream11, Games24X7 and Mobile Premier League. "People lose their life's savings in online money gaming," India's Minister for Information and Broadcasting Ashwini Vaishnaw told lawmakers in New Delhi. He said the government intends to curb the addiction and financial harm that comes with online money gaming, but will promote e-sports and social gaming.

Read more of this story at Slashdot.

Categories: Computer, News

Google Refreshes Pixel Lineup With Tensor G5 and Qi2 Charging Across Four Models

Slashdot - Wed, 2025-08-20 18:51
Google announced its Pixel 10 smartphone lineup today, introducing the Tensor G5 processor and Qi2 magnetic wireless charging across four models priced from $799 to $1,799. The base Pixel 10 adds a 5x telephoto lens for the first time at $799. The Pixel 10 Pro maintains its $999 starting price in a 6.3-inch size while the Pro XL starts at $1,199 for the 6.8-inch variant. The $1,799 Pixel 10 Pro Fold becomes the first foldable phone to achieve IP68 water and dust resistance through a redesigned gearless hinge. All models feature 3,000-nit peak brightness displays, Android 16, and Google's Material 3 Expressive interface redesign. The Tensor G5 enables on-device AI features including Magic Cue for contextual information retrieval and Camera Coach for photography guidance. Pro models gain 100x hybrid zoom capabilities through computational photography. Preorders begin today for August 28 availability, except the Pro Fold which ships October 9.

Read more of this story at Slashdot.

Categories: Computer, News

Sony Raises PS5 Prices by $50 Across All Models in US

Slashdot - Wed, 2025-08-20 18:01
Sony will increase PlayStation 5 console prices by $50 across all models in the United States starting August 21. The standard PS5 rises to $550, the Digital Edition to $500, and the PS5 Pro to $750. The company cited navigating a challenging economic environment for the increases.

Read more of this story at Slashdot.

Categories: Computer, News

Passengers Sue Delta, United Over Windowless 'Window Seats'

Slashdot - Wed, 2025-08-20 17:22
In a pair of class actions filed this week, passengers from each coast quibbled with United Airlines and Delta Air Lines' policies charging extra for window seats that are not actually beside windows, instead offering a view of a blank aircraft wall. From a report: "Delta indicated to the plaintiff and class members that the particular seats they chose had a 'window'; even though Delta knew full well they did not," the plaintiffs taking on Delta said in an 18-page complaint filed in federal court in New York, accusing the airline of false advertising and deceptive business practices. Half of Delta's fleet of nearly 1,000 aircraft comprises Boeing 737s, Boeing 757s and Airbus A321s -- all of which have at least one wall-adjacent seat with no window, according to the plaintiffs. It's where vertical air conditioning riser ducts are located, making putting a window there impossible, the competing Alaska Airlines explains on its website. But unlike Alaska and others, the plaintiffs complain, Delta advertises the seats as having a window, offering them as a "window seat" option on its seat map during checkout.

Read more of this story at Slashdot.

Categories: Computer, News

Is Rotten Tomatoes Still Reliable? A Statistical Analysis

Slashdot - Wed, 2025-08-20 16:40
An analysis of Rotten Tomatoes data reveals average Tomatometer scores have climbed steadily since Fandango's 2016 acquisition of the review aggregation platform. The average number of reviewers per mainstream film release increased by 40 to 70 critics following the purchase. New additions to the critic pool include smaller outlets such as Denerstein Unleashed and KKFI-FM Kansas City. Prior to 2016, critic and audience scores demonstrated stable correlation year-over-year. Post-acquisition data shows the two metrics diverged sharply as Tomatometer ratings rose. Fandango, America's largest movie-ticketing platform, is partially owned by NBCUniversal and Warner Bros. Discovery. In 2023 Vulture reported PR firms court reviewers from smaller outlets to secure higher Tomatometer scores before film releases.

Read more of this story at Slashdot.

Categories: Computer, News

Microsoft Warns Excel's New AI Function 'Can Give Incorrect Responses' in High-Stakes Scenarios

Slashdot - Wed, 2025-08-20 16:01
Microsoft is testing a COPILOT function in Excel that uses OpenAI's gpt-4.1-mini model to automatically fill spreadsheet cells through natural language prompts. The function can classify feedback, generate summaries, and create tables based on specified cell ranges. Microsoft warns against using the AI function for numerical calculations or scenarios involving legal, regulatory, and compliance implications because COPILOT "can give incorrect responses." The feature processes up to 100 functions every 10 minutes and cannot access information outside the spreadsheet.

Read more of this story at Slashdot.

Categories: Computer, News

Dramatic Slowdown in Melting of Arctic Sea Ice Surprises Scientists

Slashdot - Wed, 2025-08-20 14:30
The melting of sea ice in the Arctic has slowed dramatically in the past 20 years, scientists have reported, with no statistically significant decline in its extent since 2005. From a report: The finding is surprising, the researchers say, given that carbon emissions from fossil fuel burning have continued to rise and trap ever more heat over that time. They said natural variations in ocean currents that limit ice melting had probably balanced out the continuing rise in global temperatures. However, they said this was only a temporary reprieve and melting was highly likely to start again at about double the long-term rate at some point in the next five to 10 years. The findings do not mean Arctic sea ice is rebounding. Sea ice area in September, when it reaches its annual minimum, has halved since 1979, when satellite measurements began. The climate crisis remains "unequivocally real," the scientists said, and the need for urgent action to avoid the worst impacts remains unchanged. The natural variation causing the slowdown is probably the multi-decadal fluctuations in currents in the Atlantic and Pacific oceans, which change the amount of warmed water flowing into the Arctic. The Arctic is still expected to see ice-free conditions later in the century, harming people and wildlife in the region and boosting global heating by exposing the dark, heat-absorbing ocean.

Read more of this story at Slashdot.

Categories: Computer, News

US Tech Stocks Hit By Concerns Over Future of AI Boom

Slashdot - Wed, 2025-08-20 10:30
US tech stocks sold off as warnings that the hype surrounding AI could be overdone hit some of the year's best-performing shares. From a report: Nvidia, the chips group that has surged to become the world's first $4tn company on the back of AI, fell 3.5 per cent on Tuesday, while software group Palantir dropped 9.4 per cent and chip designer Arm shed 5 per cent. The tech-heavy Nasdaq Composite closed down 1.4 per cent, the biggest one-day drop for the index since August 1. The blue-chip S&P 500 fell 0.7 per cent. European and Asian markets largely followed Wall Street lower on Wednesday. [...] Japan's Nikkei 225 index fell 1.5 per cent and South Korea's Kospi slipped 0.6 per cent. Futures price indicated moderate declines when Wall Street opens. Traders pinned some of the declines in the US on a critical report on Monday authored by a branch of the Massachusetts Institute of Technology. Researchers said "95 per cent of organisations are getting zero return" from their investments in generative AI, the technology that has sent US stocks soaring to record highs in recent months.

Read more of this story at Slashdot.

Categories: Computer, News

CodeSOD: Copy of a Copy of a

The Daily WTF - Wed, 2025-08-20 08:30

Jessica recently started at a company still using Windows Forms.

Well, that was a short article. Oh, you want more WTF than that? Sure, we can do that.

As you might imagine, a company that's still using Windows Forms isn't going to upgrade any time soon; they've been using an API that's been in maintenance mode for a decade, clearly they're happy with it.

But they're not too happy- Jessica was asked to track down a badly performing report. This of course meant wading through a thicket of spaghetti code, pointless singletons, and the general sloppiness that is the code base. Some of the code was written using Entity Framework for database access, much of it is not.

While it wasn't the report that Jessica was sent to debug, this method caught her eye:

private Dictionary<long, decimal> GetReportDiscounts(ReportCriteria criteria) { Dictionary<long, decimal> rows = new Dictionary<long, decimal>(); string query = @"select ii.IID, SUM(CASE WHEN ii.AdjustedTotal IS NULL THEN (ii.UnitPrice * ii.Units) ELSE ii.AdjustedTotal END) as 'Costs' from ii where ItemType = 3 group by ii.IID "; string connectionString = string.Empty; using (DataContext db = DataContextFactory.GetInstance<DataContext>()) { connectionString = db.Database.Connection.ConnectionString; } using (SqlConnection connection = new SqlConnection(connectionString)) { using (SqlCommand command = new SqlCommand(query, connection)) { command.Parameters.AddWithValue("@DateStart", criteria.Period.Value.Min.Value.Date); command.Parameters.AddWithValue("@DateEnd", criteria.Period.Value.Max.Value.Date.AddDays(1)); command.Connection.Open(); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { decimal discount = (decimal)reader["Costs"]; long IID = (long)reader["IID"]; if (rows.ContainsKey(IID)) { rows[IID] += discount; } else { rows.Add(IID, discount); } } } } } return rows; }

This code constructs a query, opens a connection, runs the query, and iterates across the results, building a dictionary as its result set. The first thing which leaps out is that, in code, they're doing a summary (iterating across the results and grouping by IID), which is also what they did in the query.

It's also notable that the table they're querying is called ii, which is not a result of anonymization, and actually what they called it. Then there's the fact that they set parameters on the query, for DateStart and DateEnd, but the query doesn't use those. And then there's that magic number 3 in the query, which is its own set of questions.

Then, right beneath that method was one called GetReportTotals. I won't share it, because it's identical to what's above, with one difference:

string query = @" select ii.IID, SUM(CASE WHEN ii.AdjustedTotal IS NULL THEN (ii.UnitPrice * ii.Units) ELSE ii.AdjustedTotal END) as 'Costs' from ii where itemtype = 0 group by iid ";

The magic number is now zero.

So, clearly we're in the world of copy/paste programming, but this raises the question: which came first, the 0 or the 3? The answer is neither. GetCancelledInvoices came first.

private List<ReportDataRow> GetCancelledInvoices(ReportCriteria criteria, Dictionary<long, string> dictOfInfo) { List<ReportDataRow> rows = new List<ReportDataRow>(); string fCriteriaName = "All"; string query = @"select A long query that could easily be done in EF, or at worst a stored procedure or view. Does actually use the associated parameters"; string connectionString = string.Empty; using (DataContext db = DataContextFactory.GetInstance<DataContext>()) { connectionString = db.Database.Connection.ConnectionString; } using (SqlConnection connection = new SqlConnection(connectionString)) { using (SqlCommand command = new SqlCommand(query, connection)) { command.Parameters.AddWithValue("@DateStart", criteria.Period.Value.Min.Value.Date); command.Parameters.AddWithValue("@DateEnd", criteria.Period.Value.Max.Value.Date.AddDays(1)); command.Connection.Open(); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { long ID = (long)reader["ID"]; decimal costs = (decimal)reader["Costs"]; string mNumber = (string)reader["MNumber"]; string mName = (string)reader["MName"]; DateTime idate = (DateTime)reader["IDate"]; DateTime lastUpdatedOn = (DateTime)reader["LastUpdatedOn"]; string iNumber = reader["INumber"] is DBNull ? string.Empty : (string)reader["INumber"]; long fId = (long)reader["FID"]; string empName = (string)reader["EmpName"]; string empNumber = reader["EmpNumber"] is DBNull ? string.Empty : (string)reader["empNumber"]; long mId = (long)reader["MID"]; string cName = dictOfInfo[matterId]; if (criteria.EmployeeID.HasValue && fId != criteria.EmployeeID.Value) { continue; } rows.Add(new ReportDataRow() { CName = cName, IID = ID, Costs = costs * -1, //Cancelled i - minus PC TimedValue = 0, MNumber = mNumber, MName = mName, BillDate = lastUpdatedOn, BillNumber = iNumber + "A", FID = fId, EmployeeName = empName, EmployeeNumber = empNumber }); } } } } return rows; }

This is the original version of the method. We can infer this because it actually uses the parameters of DateStart and DateEnd. Everything else just copy/pasted this method and stripped out bits until it worked. There are more children of this method, each an ugly baby of its own, but all alike in their ugliness.

It's also worth noting, the original version is doing filtering after getting data from the database, instead of putting that criteria in the WHERE clause.

As for Jessica's poor performing report, it wasn't one of these methods. It was, however, another variation on "run a query, then filter, sort, and summarize in C#". By simply rewriting it as a SQL query in a stored procedure that leveraged indexes, performance improved significantly.

[Advertisement] Keep the plebs out of prod. Restrict NuGet feed privileges with ProGet. Learn more.
Categories: Computer

Pages